Mit*_*Raj 3 browser android android-intent android-webview
我想在外部浏览器中打开一些链接.在打开之前,我想在设备中显示浏览器列表.我使用Intent.ACTION_VIEW完成了这项功能.但是根据我的应用程序的要求,我想显示浏览器列表,即使设备中只有一个浏览器应用程序.任何人都对此有任何想法.谢谢.
如果您有一个浏览器应用程序,则选择器将不会启动,该URL将加载到该浏览器应用程序上.如果您有两个或更多浏览器应用程序,则android系统会启动IntentChooser显示设备上安装的所有浏览器应用程序的列表,因此用户可以选择其首选浏览器来加载URL:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.stackoverflow.com"));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
编辑: 创建自定义意图选择器:
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 = getString(R.string.chooser_title);
// Create and start the chooser
Intent chooser = Intent.createChooser(intent, title);
startActivity(chooser);
Run Code Online (Sandbox Code Playgroud)
参考这个
| 归档时间: |
|
| 查看次数: |
9358 次 |
| 最近记录: |