【发布时间】:2014-07-24 20:25:54
【问题描述】:
我想打开 WhatsApp 到一个特定的对话,并用一些字符串填充文本字段。
我拥有的代码并且我设法打开了与联系人的对话:
private void openConversationWithWhatsapp(String e164PhoneNumber){
String whatsappId = e164PhoneNumber+"@s.whatsapp.net";
Uri uri = Uri.parse("smsto:" + whatsappId);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.setPackage("com.whatsapp");
intent.putExtra(Intent.EXTRA_TEXT, "text");
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TITLE, "title");
intent.putExtra(Intent.EXTRA_EMAIL, "email");
intent.putExtra("sms_body", "The text goes here");
intent.putExtra("text","asd");
intent.putExtra("body","body");
intent.putExtra("subject","subjhect");
startActivity(intent);
}
但是文本框没有填充内容。我试图查看AndroidManifest.xml 文件,发现以下关于他们的对话活动的信息:
<activity android:theme="@style/Theme.App.CondensedActionBar" android:name="com.whatsapp.Conversation" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:windowSoftInputMode="stateUnchanged">
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
</intent-filter>
</activity>
有人知道要使用的额外功能吗? 他们是故意阻止的吗? 我在他们的FAQ 页面中看到了适用于 iOS 的 API。
【问题讨论】:
-
但是 Whatsapp 没有开放的 API。您使用的代码不保证永远有效!