3

I have a code for opening URL with browser:

Intent i = new Intent(Intent.ACTION_VIEW, uri);
startActivity(i);

My question is, if user has set up default app for opening url, is there a way to override the default app and show application choose dialog instead?

4

2 回答 2

4

我刚刚找到了解决方案。这很简单:

startActivity(Intent.createChooser(intent, title));
于 2013-06-03T07:09:31.053 回答
1

我不知道你的问题的确切答案,但有一个更复杂的决定。您可以获得安装在智能手机上的浏览器列表:

PackageManager manager = getPackageManager();
List<ResolveInfo> info = manager.queryIntentActivities(myIntent,PackageManager.MATCH_DEFAULT_ONLY);

然后手动创建一个选择对话框。

PS也许有一个更简单的解决方案......

于 2013-06-02T21:37:32.680 回答