sendBroadcast (intent) 和 startActivity(intent) 有什么不同。
为什么这不起作用:
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.setData( Uri.parse( "sms:0533"));
smsIntent.putExtra("sms_body", "The SMS text");
sendBroadcast(smsIntent);
最佳答案
sendBroadCast()
发送一个全局广播,该广播将被设置为接收该广播的任何 BroadcastReceivers
接收。
startActivity()
尝试根据您指定的类名或 Intent Action(它是一个字符串)启动一个 Activity。
在你的情况下 Intent.ACTION_SENDTO
是一个 Intent Action,因此需要 startActivity()
来自文档:
Standard Activity Actions
These are the current standard actions that Intent defines for launching activities (usually through startActivity(Intent). The most important, and by far most frequently used, are ACTION_MAIN and ACTION_EDIT.
关于android - 发送广播 VS 启动 Activity 。有什么不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14184220/