【发布时间】:2017-06-21 19:29:10
【问题描述】:
几天后我被困在这里,我正在尝试将选定联系人的短信(从我的应用程序中预定义的设置)发送到什么应用程序,在 stackoverflow 的帮助下,我找到了两种将短信发送到 whatsapp 的方法。
第一种方法: 一种方法是将短信转发到whatsapp 好吧,但不能选择联系人,联系人可以从whatsapp 中选择,但我不希望那样。我希望联系人也应该从我的应用程序中选择。现在
第二种方法:第二种方法与第一种相反。此方法将选定的联系人发送到whatsapp 发送短信,但不发送(预定义短信)。
我的问题是我希望这两个东西都应该从我的应用程序 sms+Contact 传递给whatsapp。当我尝试合并时,这两种方法都会出错。请帮我
这是我的第一种方法和第二种方法的代码。
//1st method: for forward sms to whatsapp
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = "YOUR TEXT HERE";
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(waIntent);
//2nd method: send sms with selected contact but not with predefined sms
void openWhatsappContact(String number) {
Uri uri = Uri.parse("smsto:" + number);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.setPackage("com.whatsapp");
startActivity(i);
//here i am trying to send both SMS and contact from my Android app but not working and get error.
Uri uri = Uri.parse("smsto:" + "065214585756");
Intent sendIntent = new Intent(Intent.ACTION_SENDTO, uri);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Hai Good Morning");
sendIntent.putExtra("chat",true);
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
请任何人帮助我。我该怎么做。
【问题讨论】:
-
我猜不幸的是.. 它不是 p o s s i b l e
-
@sajidHussain 尚不可能,因为 whatsapp 不提供从其他应用程序发送文本的这种功能。
标签: android android-intent sms whatsapp