且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将短信从我的android应用程序发送到Whatsapp到特定联系人

更新时间:2023-01-01 16:34:09

这对我有用.

whatsapp应用程序未读取参数'body',请改用'Intent.EXTRA_TEXT'.

The parameter 'body' gets not read by the whatsapp app, use 'Intent.EXTRA_TEXT' instead.

通过设置"phoneNumber",您可以指定要在whatsapp中打开的联系人.

By setting the 'phoneNumber' you specify the contact to open in whatsapp.

    Intent sendIntent = new Intent(Intent.ACTION_SENDTO, 
           Uri.parse("smsto:" + "" + phoneNumber + "?body=" + encodedMessage));
    sendIntent.putExtra(Intent.EXTRA_TEXT, message);
    sendIntent.setPackage("com.whatsapp");
    startActivity(sendIntent);