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.
Try using Intent.createChooser:
Uri uri = Uri.parse( "http://www.google.com" );
startActivity(Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), "Choose browser"));
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With