Reputation: 8555
How can I give chance to user to choose application for opening a link?
For example, user has 3 browsers and he set Firefox as default browser. I want to give chance to open a link with Opera to user when user long click link.
Upvotes: 7
Views: 3943
Reputation: 6235
Try using Intent.createChooser:
Uri uri = Uri.parse( "http://www.google.com" );
startActivity(Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), "Choose browser"));
Upvotes: 6
Reputation: 91351
PackageManager.queryIntentActivities() returns all of the activities that can handle a particular Intent.
With the Intent you passed in to it, to now use it to launch one of the activities in the returned list, you use Intent.setComponent with a ComponentName built from the packageName and name of the activity you want in that list.
Upvotes: 4
Reputation: 6376
You can create a Uri with your URL and pass it to an Intent like so:
Uri uri = Uri.parse( "http://www.google.com" );
startActivity( new Intent( Intent.ACTION_VIEW, uri ) );
Is this what you're looking to accomplish?
Upvotes: -1