0

I have developed one wallpaper application in which I want to add share button to share a photo on whatsapp. Here is my code( but that code is only for any text msg) I want to share a photo.

Please respond with the code where in I can select a wallpaper from my application and send to whatsapp's particular contact.

case R.id.save:
        InputStream y11 = getResources().openRawResource(to);
        Bitmap b11 = BitmapFactory.decodeStream(y11);
        Intent waIntent = new Intent(Intent.ACTION_SEND);
        waIntent.setType("image/*");

        waIntent.setPackage("com.whatsapp.android");
        waIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, to);
        startActivity(Intent.createChooser(waIntent, "Share with"));
9477
  • 3
  • 6

2 Answers2

0

Replace

waIntent.setType("text/plain");

with

waIntent.setType("image/png");
arshu
  • 11,805
  • 3
  • 23
  • 21
0

the package name is wrong. try: com.whatsapp and this code is to share image via whatsapp

private void shareIt(Uri uri) {
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("image/*");
        sharingIntent.setPackage("com.whatsapp");
        sharingIntent.putExtra(Intent.EXTRA_TEXT,"Shared via my app");
        sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
        startActivity(Intent.createChooser(sharingIntent, "share with"));
    }
A Ahmed
  • 1
  • 4