当我触摸发送短信按钮时,我想打开已安装的消息应用程序(WhatsApp等)的对话框列表



我使用下面的代码。

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://android-developers.blogspot.in/2012/02/share-with-intents.html

也检查一下:
http://developer.android.com/training/sharing/send.html

最新更新