Search code examples
androidandroid-activitysms

ACTION_SEND used to send sms


I want to open native application to send sms but there should be already phone number. I found ACTION_SEND but when I'm calling my function it's return 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 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 that's is simple but I don't know why it does not work and I can not find any helfull information.

Thanks for any advice.


Solution

  • Why, this should 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);