Robert Kerr
Robert Kerr

Reputation: 1329

Android unable to display chooser

When calling startActivity with a configured chooser intent, the Android chooser is not displaying any list of applications which can handle the intent. I suspect my handling activity is not configured correctly, but not combination of intent-filters has cause it to display. Disclaimer: This is for an online course.

static private final String URL = "http://www.google.com";
Intent baseIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL));
Intent chooserIntent = Intent.createChooser(baseIntent, CHOOSER_TEXT);
startActivity(chooserIntent);

The handling activity:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="http" />
</intent-filter>

A chooser never displays. Android launches chrome instead. This happens both on emulator, and on my touchpad.

Upvotes: 0

Views: 62

Answers (1)

Ali Behzadian Nejad
Ali Behzadian Nejad

Reputation: 9044

Edit your intent-filter as below:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="http" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Upvotes: 1

Related Questions