简体   繁体   中英

How to share a image from my app to whatsapp in android?

I receive an error when I press a Button .

InputStream y11 = getResources().openRawResource(R.drawable.step_000);
Bitmap b11 = BitmapFactory.decodeStream(y11);

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.setPackage("com.whats app.android");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, b11);
startActivity(Intent.createChooser(intent, "Share with"));

You can try like this;

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/png");

Uri uri = Uri.parse("android.resource://your package name/"+R.drawable.ic_launcher);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello, This is test Sharing");
startActivity(Intent.createChooser(shareIntent, "Send your image"));

Also look into this: Returning an Image to whatsapp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM