我使用下面的代码。
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(Uri.parse("smsto:" + phno));
sendIntent.putExtra("sms_body", msg);
sendIntent.putExtra("exit_on_sent", true);
startActivity(sendIntent);
我还应该添加什么?
您正在寻找通过意图分享,类似于:
Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
//the line below is optional
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
// Add data to the intent, the receiving app will decide what to do with it.
intent.putExtra(Intent.EXTRA_SUBJECT, “Some Subject Line”);
intent.putExtra(Intent.EXTRA_TEXT, “Body of the message”);
也可以使用createChooser()
:
startActivity(Intent.createChooser(intent, “How do you want to share?”));
参考:
如何过滤特定应用的ACTION_SEND意图(并为每个应用设置不同的文本)
也检查一下:
http://developer.android.com/training/sharing/send.html