Android 分享图片到WhatsApp,Messenger,Facebook
简单实现通过Intent 跳转传参数
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
if(share.equals("whatsapp")){
//Target whatsapp:
shareIntent.setPackage("com.whatsapp");
}else if(share.equals("messenger")){
//Target messenger:
shareIntent.setPackage("com.facebook.orca");
}else if(share.equals("facebook")){
//Target facebook:
shareIntent.setPackage("com.facebook.katana");
}
//Add text and then Image URI
shareIntent.putExtra(Intent.EXTRA_TEXT, "文字内容");
//照片需要转成Uri格式
//单张照片
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
//多张图片
ArrayList<Uri> uriList = new ArrayList<Uri>();
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
startActivity(shareIntent)