Reputation: 64904
I a using this code yo show the installed browser application:
Log.i(TAG, "Entered startImplicitActivation()");
// TODO - Create a base intent for viewing a URL
// (HINT: second parameter uses Uri.parse())
Intent baseIntent = null;
baseIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.google.com"));
// TODO - Create a chooser intent, for choosing which Activity
// will carry out the baseIntent
// (HINT: Use the Intent class' createChooser() method)
Intent chooserIntent = Intent.createChooser(baseIntent, "Choose App");
// TODO - Start the chooser Activity, using the chooser intent
Log.i(TAG, "Chooser Intent Action:" + chooserIntent.getAction());
startActivity(chooserIntent);
But it opens the link directly in the default browser app. why?
I have created and installed another simple browser app, that has this intent-fiilter
:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
</intent-filter>
Upvotes: 1
Views: 2367
Reputation: 671
The way I solved the problem was by adding android:host="www.google.com"
to the in the myBrowser app. From what I understand, when I was launching the chooser and the it's associated intent it was looking for an app with ACTION_VIEW
and the capability of the URL "http://www.google.com". It was not finding myBrowser because it was only set to receive the "http" (android:scheme="http"
), adding the host allowed my Intent Chooser to recognize the myBrowser app.
Please can someone correct me if this explanation is incorrect.
Upvotes: 0
Reputation: 757
your emulator have only one app which accepts those kind of Intents , In your case only one browser is present so it directly redirects.
try by adding default category once and check EDIT
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
</intent-filter>
Upvotes: 1