ACTION_SEND用于发送短信

Rob*_*ert 8 sms android android-activity

我想打开本机应用程序发送短信但应该已经有电话号码.我找到了ACTION_SEND,但是当我调用我的函数时,返回错误:

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) }
Run Code Online (Sandbox Code Playgroud)

我的代码在这里提出:

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

我知道这很简单,但我不知道为什么它不起作用,我找不到任何有用的信息.

谢谢你的建议.

Lon*_*kly 51

为什么,这应该工作正常.http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO

看看我的代码:

Uri uri = Uri.parse("smsto:0800000123");   
Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
it.putExtra("sms_body", "The SMS text");   
startActivity(it); 
Run Code Online (Sandbox Code Playgroud)

  • Uri uri = Uri.parse("smsto:"); 打开消息不会自动发送到任何号码 (3认同)