Click here to Skip to main content
14,774,061 members
Home » Discussions » Android
   

Android

 
GeneralRe: What are the vulnerabilities of utilizing file systems instead of SQLite? Pin
AndroidVH16-May-18 20:40
MemberAndroidVH16-May-18 20:40 
GeneralRe: What are the vulnerabilities of utilizing file systems instead of SQLite? Pin
Richard MacCutchan16-May-18 21:33
mveRichard MacCutchan16-May-18 21:33 
GeneralRe: What are the vulnerabilities of utilizing file systems instead of SQLite? Pin
AndroidVH16-May-18 23:51
MemberAndroidVH16-May-18 23:51 
QuestionMobile development Pin
Bivhab Sarker7-May-18 5:22
MemberBivhab Sarker7-May-18 5:22 
AnswerRe: Mobile development Pin
Member 138164587-May-18 21:16
MemberMember 138164587-May-18 21:16 
AnswerRe: Mobile development Pin
David Crow8-May-18 3:34
MemberDavid Crow8-May-18 3:34 
QuestionWho updates the view in mvp and mvvm in android Pin
Member 138137096-May-18 0:05
MemberMember 138137096-May-18 0:05 
QuestionHow can i send a hyperlink in my sms code? Pin
AlexanderBlade1-May-18 9:31
MemberAlexanderBlade1-May-18 9:31 
Researching for days and found lots of code using casting from TextView and doing :
textView.setMovementMethod(LinkMovementMethod.getInstance());


but I want to take the text from EditText object then append html formated text to the fetched EditText entry like this:
String result = getResources().getString(R.string.my_html);
                    String strMsg=message.getText().toString();

                   
           
                String msg=strMsg + " "+ result;
             
                String phoneNumber=phone.getText().toString();


How can I make a blend of regular text and html hyperlink?

My java code:

public class ExumaActivity extends AppCompatActivity {
  
private final static int SEND_SMS_PERMISSION_REQUEST_CODE=111;
private Button sendMessage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_exuma);

       
        Bundle extras=getIntent().getExtras();
       

        sendMessage=(Button) findViewById(R.id.send_message);
        final EditText phone=(EditText)findViewById(R.id.phone_no);

        sendMessage.setEnabled(false);
        if(checkPermission(Manifest.permission.SEND_SMS)){
                sendMessage.setEnabled(true);
        }else{
            ActivityCompat.requestPermissions(this,new String[] {Manifest.permission.SEND_SMS},SEND_SMS_PERMISSION_REQUEST_CODE);

        }


        sendMessage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
          
            

                final EditText message=(EditText)findViewById(R.id.message);

            
                String result = getResources().getString(R.string.my_html);
                    String strMsg=message.getText().toString();

                   
           
                String msg=strMsg + " "+ result;
             
                String phoneNumber=phone.getText().toString();

                if(!TextUtils.isEmpty(msg) && !TextUtils.isEmpty(phoneNumber)){
                        if(checkPermission(Manifest.permission.SEND_SMS)){
                            SmsManager smsManager= SmsManager.getDefault();
                            smsManager.sendTextMessage(phoneNumber ,null,msg,null,null);
                }else{
                    Toast.makeText(ExumaActivity.this,"Permission Denied",Toast.LENGTH_SHORT).show();
                }
            }else{
                    Toast.makeText(ExumaActivity.this,"Enter a messand and a phone number",Toast.LENGTH_SHORT).show();
                }


            }


    });

    }

    private boolean checkPermission(String permission){

        int checkPermission=ContextCompat.checkSelfPermission(this,permission);
        return checkPermission==PackageManager.PERMISSION_GRANTED;
    }

    
    Fragment requestingFragment;

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permission, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permission, grantResults);
        if(requestingFragment!=null)
            requestingFragment.onRequestPermissionsResult(requestCode, permission, grantResults);

          switch(requestCode){
          case SEND_SMS_PERMISSION_REQUEST_CODE:
          if(grantResults.length>0 && grantResults[0]==PackageManager.PERMISSION_GRANTED){
           sendMessage.setEnabled(true);
         }
        break;
         }
    }
   

}


Then in strings.xml:
<string name="my_html"><![CDATA[<a href="http://google.com/">Go to google!</a>]]></string>


modified 1-May-18 17:09pm.

QuestionRe: How can i send a hyperlink in my sms code? Pin
David Crow1-May-18 17:38
MemberDavid Crow1-May-18 17:38 
AnswerRe: How can i send a hyperlink in my sms code? Pin
AlexanderBlade2-May-18 6:31
MemberAlexanderBlade2-May-18 6:31 
QuestionRe: How can i send a hyperlink in my sms code? Pin
David Crow2-May-18 6:33
MemberDavid Crow2-May-18 6:33 
Questionlistening to android key board events Pin
Member 1360034126-Apr-18 4:03
professionalMember 1360034126-Apr-18 4:03 
QuestionRe: listening to android key board events Pin
Jochen Arndt26-Apr-18 4:26
professionalJochen Arndt26-Apr-18 4:26 
QuestionHow to get the coordinates(X,Y) in correlation to root view Pin
Member 1377943514-Apr-18 5:23
MemberMember 1377943514-Apr-18 5:23 
QuestionRe: How to get the coordinates(X,Y) in correlation to root view Pin
David Crow16-Apr-18 9:14
MemberDavid Crow16-Apr-18 9:14 
AnswerRe: How to get the coordinates(X,Y) in correlation to root view Pin
Member 1377943516-Apr-18 9:19
MemberMember 1377943516-Apr-18 9:19 
SuggestionRe: How to get the coordinates(X,Y) in correlation to root view Pin
David Crow16-Apr-18 9:21
MemberDavid Crow16-Apr-18 9:21 
Questionabout sms app Pin
Member 137656286-Apr-18 0:45
MemberMember 137656286-Apr-18 0:45 
AnswerRe: about sms app Pin
Richard Deeming6-Apr-18 3:04
mveRichard Deeming6-Apr-18 3:04 
QuestionAndroid Studio Pin
Member Hemal19-Mar-18 21:51
MemberMember Hemal19-Mar-18 21:51 
AnswerRe: Android Studio Pin
Richard MacCutchan19-Mar-18 23:08
mveRichard MacCutchan19-Mar-18 23:08 
QuestionIntegrate channels in your mobile app. Pin
Tarik M'ghari19-Mar-18 9:59
MemberTarik M'ghari19-Mar-18 9:59 
QuestionHow to change IP address Pin
ryanp4713-Mar-18 21:29
Memberryanp4713-Mar-18 21:29 
AnswerRe: How to change IP address Pin
Richard MacCutchan13-Mar-18 22:57
mveRichard MacCutchan13-Mar-18 22:57 
QuestionRe: How to change IP address Pin
David Crow16-Mar-18 17:45
MemberDavid Crow16-Mar-18 17:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.