与WhatsApp共享数据

时间:2015-11-26 16:07:05

标签: android whatsapp

我想知道我是否可以将我的Android应用程序中的文本数据发送到WhatsApp而不显示WhatsApp的联系人列表,我只需要在我的Android代码内部设置消息和手机号码?

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

public void sendWhatsappMessageToMsisdn(String contactNumber)
{
       Uri uri = Uri.parse("smsto:" + contactNumber);
       Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
       intent.setPackage("com.whatsapp");  
       intent.putExtra(Intent.EXTRA_TEXT, "This is the message you want to send");
       startActivity(Intent.createChooser(intent, ""));
}