-1

I want to share text with image on WhatsApp and Facebook, I did for Whatsapp but the issue is in WhatsApp business because of package com.whatsapp and com.whatsapp.w4b but how to set both at once, and facebook only sent image not text, so to resolve the issue, please.

My code for sharing via WhatsApp, Facebook, and Twitter.

private void share(String text, Uri uri, int type) {
    Intent share = new Intent(Intent.ACTION_SEND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    share.setType("image/*");
    switch (type) {
        case 2:
            share.setPackage("com.whatsapp");
            break;
        case 3:
            share.setPackage("com.facebook.katana");
            break;
        case 4:
            share.setPackage("com.twitter.android");
            break;
        case 1:
        default:
            break;
    }
    share.putExtra(Intent.EXTRA_STREAM, uri);
    share.putExtra(Intent.EXTRA_TEXT, text);
    startActivity(Intent.createChooser(share, "Select"));
}
Attaullah
  • 3,856
  • 3
  • 48
  • 63

1 Answers1

-1

share.setPackage("pakagename");

is working for whatsapp and twitter but not for facebook so use facebook sdk .

  • yes but the issue is in facebook is hash key.. working in my device but not in other device i do not know. – Attaullah Jan 02 '20 at 01:02
  • `share.setPackage("com.facebook.katana")` for facebook or `share.setPackage("com.facebook.orca")` for messenger both work perfectly fine. Have no idea what you're talking about. – Slobodan Antonijević May 04 '20 at 15:04