打开Android中的链接时,显示浏览器列表 [英] Show browser list when opening a link in android

查看:174
本文介绍了打开Android中的链接时,显示浏览器列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  

我想打开外部浏览器一定的联系。开场前我想显示在设备浏览器的列表。我没有使用Intent.ACTION_VIEW此功能。但按照我的应用程序的要求,我想即使只有一个在该装置的浏览器应用程序显示的浏览器列表。做任何一件有关于这个的想法。谢谢。



解决方案

如果你有一个浏览器应用程序,选择器将无法启动,URL将在该浏览器应用程序加载。如果有两个或更多的浏览器应用程序,Android系统推出的所有浏览器的 IntentChooser 节目列表安装在设备上的应用程序,使用户可以选择他的preferred浏览器加载的网址:

 意向意图=新意图(Intent.ACTION_VIEW);
intent.setData(Uri.parse(http://www.stackoverflow.com));
startActivity(意向);

编辑:
创建自定义意图选配:

 意向意图=新意图(Intent.ACTION_VIEW);
intent.setData(Uri.parse(http://www.stackoverflow.com));//总是使用字符串资源的UI文本。这是说像分享这张照片。
。字符串title = getResources()的getText(R.string.chooser_title);
//创建并启动选择器
意向选择器= Intent.createChooser(意向,职务);
startActivity(选配);

I want to open some links in external browser. Before opening I want to display the list of browsers in the device. I did this functionality using Intent.ACTION_VIEW. But as per my app's requirement, I want to display the list of browsers even if there is only one browser application in the device. Do any one have any idea about this. Thanks.

解决方案

If you have one browser application , the chooser will not launched , the URL will be loaded on that browser application. If you have two or more browser applications, the android system launch an IntentChooser the show the list of all browser apps installed on the device , so the user can choose his preferred browser to load the URL :

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.stackoverflow.com"));
startActivity(intent); 

EDIT : to create your custom Intent Chooser :

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.stackoverflow.com"));

// Always use string resources for UI text. This says something like "Share this photo with"
String title = getResources().getText(R.string.chooser_title);
// Create and start the chooser
Intent chooser = Intent.createChooser(intent, title);
startActivity(chooser);

refer this

这篇关于打开Android中的链接时,显示浏览器列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆