我通过WhatsApp分享我的图片 - 但我必须选择收件人.这是我的代码:
public static void shareImage(Context context,String path, String text, String otherAppPackage){
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
share.setPackage("com.whatsapp");
share.putExtra(android.content.Intent.EXTRA_SUBJECT, getSubject(context));
if (text!=null){
share.putExtra(Intent.EXTRA_TEXT,text);
}
if (path!=null){
share.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(new File(path)));
}
context.startActivity(Intent.createChooser(share, context.getString(R.string.share_via)));
}
Run Code Online (Sandbox Code Playgroud)
我希望直接与某人分享.你们当中有些人知道我该怎么做.谢谢
您可以使用Intent.ACTION_SENDTO,但消息不会复制到剪贴板:
Uri uri = Uri.parse("smsto:+123456789");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.setPackage("com.whatsapp");
it.putExtra("sms_body", "The SMS text");
it.putExtra("chat",true);
startActivity(it);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6640 次 |
| 最近记录: |