0

Android Chooser is showing duplicate apps when trying to share an image with Text.

Uri uri = FileProvider.getUriForFile(getBaseContext(), getApplicationContext().getPackageName() + ".fileprovider", inviteImagePath);
            intent.setAction(Intent.ACTION_SEND);
            intent.putExtra(Intent.EXTRA_TEXT, msg);
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            intent.setType("image/*");

I am getting 3 Facebook Apps and 2 Messenger Apps and 2 Twitter Apps.

The snapshot with the duplicate Apps

For Example, Take Fb. I want to show only post the image as a feed and not as a Profile Picture. How to attain it.

Aman Verma
  • 3,155
  • 7
  • 30
  • 60
  • You would need to use some Facebook-supplied API, rather than `ACTION_SEND`. Also, please use a concrete MIME type, not a wildcard, as you are the supplier of the content. BTW, you can replace `getBaseContext()` with `this` and replace `getApplicationContext().getPackageName()` with `getPackageName()` to simplify your code a bit. – CommonsWare May 25 '20 at 00:02
  • What about twitter? – Aman Verma May 25 '20 at 00:03
  • And Plus I am trying to create my own custom list using resolveinfo. I am still getting duplicate apps. As you can see in the picture, "Your Story" is written below the appname. How to get the Name using resolveinfo I Searched the whole Object and i can't find it – Aman Verma May 25 '20 at 00:05
  • "What about twitter?" -- what about it? "I am still getting duplicate apps" -- if you are using `queryIntentActivities()`, that returns activities, not apps. An app can have more than one activity, including having more than one activity that handles `ACTION_SEND`. "How to get the Name using resolveinfo" -- you don't, at least not through something like `queryIntentActivities()`, as [share targets](https://developer.android.com/training/sharing/receive) are not published that way. – CommonsWare May 25 '20 at 00:12
  • with this - getAppResolveInfo().activityInfo.loadLabel(getPackageManager()), I am getting the name of the Label for Each Apps. For Facebook, it is giving me the correct name but somehow Facebook Messenger is not giving me the correct details. I further search on How to? – Aman Verma May 25 '20 at 01:02

0 Answers0