Bhoot
Bhoot

Reputation: 2633

PendingIntent does not create intent chooser

I am using Chrome custom tabs to open URL in my application. I am trying to configure Share feature in its action button which requires PendingIntent as one of its arguments. I am returning the PendingIntent as follows:

private static PendingIntent getShareIntent(@NotNull Context context, @NotNull Uri uri)
{
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, uri.toString());
    return PendingIntent
        .getActivity(context, (int) System.currentTimeMillis(),
            shareIntent, PendingIntent.FLAG_CANCEL_CURRENT);
}

The problem is that when the share button is clicked the first time, it creates a chooser (shown below) to select application to be used for sharing, but does not do it after the first time. This is shown just once. After user has made a choice, that becomes the default application and all subsequent clicks on share button opens in the application selected the first time. I have used Intent.createChooser(shareIntent, "Share via") while returing pendingIntent, but to no avail. Please help.

Intent Chooser

Upvotes: 0

Views: 336

Answers (1)

Bhoot
Bhoot

Reputation: 2633

Turns out that it did not work on Samsung Note 3 Neo (SM-N750). It worked fine with Nexus devices I tested with. Wasted half a day trying to fix this. Such is life.

Upvotes: 0

Related Questions