ACTION_SEND is used to send SMS

I want to open my own application for sending SMS, but there must already be a phone number. I found ACTION_SEND, but when I call my function, it returns an error that:

04-26 11:59:15.991: ERROR/AndroidRuntime(20198): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SENDTO (has extras) } 

My code is presented here:

  private void smsSend(String number) { Intent intent = new Intent(Intent.ACTION_SENDTO, null); intent.putExtra(Intent.EXTRA_PHONE_NUMBER, number); startActivity(intent); } 

I know this is simple, but I do not know why this does not work, and I cannot find any reference information.

Thanks for any advice.

+7
source share
3 answers

Why should this work fine. http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO

Check out my code:

 Uri uri = Uri.parse("smsto:0800000123"); Intent it = new Intent(Intent.ACTION_SENDTO, uri); it.putExtra("sms_body", "The SMS text"); startActivity(it); 
+40
source

I think you should use the following code:

 Intent sendIntent = new Intent(Intent.ACTION_VIEW); //use to fill the sms body StringBuilder uri = new StringBuilder("sms:" + mobilenumber); sendIntent.putExtra("sms_body", ""); sendIntent.setType("vnd.android-dir/mms-sms"); sendIntent.setData(""); startActivity(sendIntent); 

I think this can help you.

+1
source

Thanks for the info! Here is my solution using the previous information:

  if (url.indexOf ("tel:")> -1) {
     startActivity (new Intent (Intent.ACTION_DIAL, Uri.parse (url)));
     return true;
 }
 else if (url.indexOf ("sms:")> -1) {
     startActivity (new Intent (Intent.ACTION_SENDTO, Uri.parse (url)));
     return true;
 }

Sincerely.

+1
source

All Articles