I'm sharing my images via WhatsApp - but I have to choose the recipient. Here is my code:
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)));
}
I wold like to share with someone directly. Does some of you know how can I do this. Thanks
You can use Intent.ACTION_SENDTO
, but message is not copied to clipboard then:
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);