Issue
I have an app that can open web links to a specific website. To facilitate usage, the app also has an option to open the current page of the app in the user's web browser. Unfortunately, if the user chooses the "Always" option when opening a link with the app, he can no longer open the links in his web browser from the app. Is there a way around this ?
Solution
The following method works for all implicit intents - not limited to your question about browsers.
Generally. when you issue an implicit intent (like ACTION_VIEW), the host Android device will check to see whether there is a default app to handle the intent. If there is a default app, then, by default, android will automatically redirect to the app.
However, you can force an app chooser for implicit intents. For this, you need to use Intent.createChooser() method. See this example:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url)); // only used based on your example.
String title = "Select a browser";
// Create intent to show the chooser dialog
Intent chooser = Intent.createChooser(intent, title);
// Verify the original intent will resolve to at least one activity
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(chooser);
}
Answered By - Vishal Vasani
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.