Android 通过编程将WhatsApp发送到联系人列表,而无需选择
我正在为android开发一个新的应用程序。我基本上想通过我的应用程序向手机中的联系人或号码列表发送WhatsApp消息。 这里最重要的一点是,我希望在不使用选择器的情况下执行此操作。换句话说,我的应用程序将检索我的所有联系人,然后在向列表发送消息之前进行一些过滤,而无需用户手动使用选择器 我可以在不启动设备的情况下执行此操作吗?Android 通过编程将WhatsApp发送到联系人列表,而无需选择,android,android-intent,Android,Android Intent,我正在为android开发一个新的应用程序。我基本上想通过我的应用程序向手机中的联系人或号码列表发送WhatsApp消息。 这里最重要的一点是,我希望在不使用选择器的情况下执行此操作。换句话说,我的应用程序将检索我的所有联系人,然后在向列表发送消息之前进行一些过滤,而无需用户手动使用选择器 我可以在不启动设备的情况下执行此操作吗? 非常感谢您的帮助。通过任何应用程序共享 public void sendAppMsg(View view) { Intent intent = new In
非常感谢您的帮助。通过任何应用程序共享
public void sendAppMsg(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
String text = " message you want to share..";
// change with required application package
intent.setPackage("PACKAGE NAME OF THE APPLICATION");
if (intent != null) {
intent.putExtra(Intent.EXTRA_TEXT, text);//
startActivity(Intent.createChooser(intent, text));
} else {
Toast.makeText(this, "App not found", Toast.LENGTH_SHORT)
.show();
}
}
注意:根据您的要求更改*应用程序包名称,如
示例:使用
Whatsapp:intent.setPackage(“com.Whatsapp”)代码>
Linkedin:intent.setPackage(“com.Linkedin.android”)代码>
Twitter:intent.setPackage(“com.Twitter.android”)代码>
Facebook:intent.setPackage(“com.Facebook.katana”)代码>
GooglePlus:intent.setPackage(“com.google.android.apps.plus”)代码>感谢Amarbir的快速回复。你的代码使用了我强调我不想使用的选择器。我的应用程序将有一个联系人列表,它需要在后台向所有联系人发送一条Whatsapp消息,而无需使用选择器。检查我的答案