Click here to Skip to main content
15,880,796 members
Home / Discussions / Android
   

Android

 
GeneralRe: What are the vulnerabilities of utilizing file systems instead of SQLite? Pin
AndroidVH16-May-18 19:40
AndroidVH16-May-18 19:40 
GeneralRe: What are the vulnerabilities of utilizing file systems instead of SQLite? Pin
Richard MacCutchan16-May-18 20:33
mveRichard MacCutchan16-May-18 20:33 
GeneralRe: What are the vulnerabilities of utilizing file systems instead of SQLite? Pin
AndroidVH16-May-18 22:51
AndroidVH16-May-18 22:51 
QuestionMobile development Pin
Bivhab Sarker7-May-18 4:22
Bivhab Sarker7-May-18 4:22 
AnswerRe: Mobile development Pin
Member 138164587-May-18 20:16
Member 138164587-May-18 20:16 
AnswerRe: Mobile development Pin
David Crow8-May-18 2:34
David Crow8-May-18 2:34 
QuestionWho updates the view in mvp and mvvm in android Pin
Member 138137095-May-18 23:05
Member 138137095-May-18 23:05 
QuestionHow can i send a hyperlink in my sms code? Pin
AlexanderBlade1-May-18 8:31
AlexanderBlade1-May-18 8: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 16:38
David Crow1-May-18 16:38 
AnswerRe: How can i send a hyperlink in my sms code? Pin
AlexanderBlade2-May-18 5:31
AlexanderBlade2-May-18 5:31 
QuestionRe: How can i send a hyperlink in my sms code? Pin
David Crow2-May-18 5:33
David Crow2-May-18 5:33 
Questionlistening to android key board events Pin
Member 1360034126-Apr-18 3:03
professionalMember 1360034126-Apr-18 3:03 
QuestionRe: listening to android key board events Pin
Jochen Arndt26-Apr-18 3:26
professionalJochen Arndt26-Apr-18 3:26 
QuestionHow to get the coordinates(X,Y) in correlation to root view Pin
Member 1377943514-Apr-18 4:23
Member 1377943514-Apr-18 4:23 
QuestionRe: How to get the coordinates(X,Y) in correlation to root view Pin
David Crow16-Apr-18 8:14
David Crow16-Apr-18 8:14 
AnswerRe: How to get the coordinates(X,Y) in correlation to root view Pin
Member 1377943516-Apr-18 8:19
Member 1377943516-Apr-18 8:19 
SuggestionRe: How to get the coordinates(X,Y) in correlation to root view Pin
David Crow16-Apr-18 8:21
David Crow16-Apr-18 8:21 
Questionabout sms app Pin
Member 137656285-Apr-18 23:45
Member 137656285-Apr-18 23:45 
AnswerRe: about sms app Pin
Richard Deeming6-Apr-18 2:04
mveRichard Deeming6-Apr-18 2:04 
QuestionAndroid Studio Pin
Member Hemal19-Mar-18 20:51
Member Hemal19-Mar-18 20:51 
AnswerRe: Android Studio Pin
Richard MacCutchan19-Mar-18 22:08
mveRichard MacCutchan19-Mar-18 22:08 
QuestionIntegrate channels in your mobile app. Pin
Tarik M'ghari19-Mar-18 8:59
Tarik M'ghari19-Mar-18 8:59 
QuestionHow to change IP address Pin
ryanp4713-Mar-18 20:29
ryanp4713-Mar-18 20:29 
AnswerRe: How to change IP address Pin
Richard MacCutchan13-Mar-18 21:57
mveRichard MacCutchan13-Mar-18 21:57 
QuestionRe: How to change IP address Pin
David Crow16-Mar-18 16:45
David Crow16-Mar-18 16: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.