我正在使用以下代码来共享来自我的应用程序的所有消息传递应用程序的文本
String shareBody = "Here is the share content body";
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_using)));参考:Android: Share plain text using intent (to all messaging apps)
如何为Whatsup设置特定文本,为其他应用程序设置另一个文本?
发布于 2016-02-06 20:19:05
尝试与Action.SEND共享
这样做:
Intent myIntentForWhatsapp = new Intent(Intent.ACTION_SEND);
myIntentForWhatsapp.setType("text/plain");
myIntentForWhatsapp.setPackage("com.whatsapp");
myIntentForWhatsapp.putExtra(Intent.EXTRA_TEXT, "Hallo, this is a msg");
try {
activity.startActivity(myIntentForWhatsapp);
} catch (android.content.ActivityNotFoundException ex) {
System.out.println("Whatsapp not installed.");
}发布于 2016-02-06 20:19:17
如果要指定只打开WhatsApp应用程序的意图,则执行以下操作
PackageManager manager = context.getPackageManager();
try {
Intent i = manager.getLaunchIntentForPackage("com.whatsapp");
if (i == null) {
}
i.addCategory(Intent.CATEGORY_LAUNCHER);
context.startActivity(i);
} catch (PackageManager.NameNotFoundException e) {
}https://stackoverflow.com/questions/35245946
复制相似问题