1

I am using Global share intent to share some text as follows;

Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "Some Text");
        startActivity(intent);

The issue is I want to show all the available Apps to share the text with even if the user has set a default app as the image below showsenter image description here

aya salama
  • 903
  • 1
  • 10
  • 29
  • A simple solution is metioned here: https://stackoverflow.com/questions/19511976/is-it-possible-to-hide-some-application-in-intent-appchooser/19512128#19512128 – KnIfER Jan 23 '20 at 10:40

2 Answers2

0

how about using ShareActionProvider

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto">

    <item
        android:id="@+id/menu_item_share"
        app:showAsAction="ifRoom"
        android:title="Share"
        app:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
    ...
</menu>

it should not ask for Just Once and 'Always` options. You can add this menu in "Menu options" or wherever you want.

Nayan Srivastava
  • 3,655
  • 3
  • 27
  • 49
0

There is a way to clear yourself from being the defailt activity using PackageManager, but you cannot clear other activities.

So as workaround you can build your own UI for that purpose. For example put in BottomSheet data which you got that way:

PackageManager manager = context.getPackageManager();
List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);
if (infos.size() > 0) {
   //do UI stuff
} else { 
    //No Application can handle your intent 
}  

It can looks like as:

enter image description here

Divers
  • 9,531
  • 7
  • 45
  • 88