android 调用系统浏览器方法

来源:互联网 发布:北大培文杯网络赛 编辑:程序博客网 时间:2024/05/21 09:55

这里我提供两种调用系统浏览器方法,是我公司项目中某个模块用到的。分享给大家,希望对大家能有所帮助。


1.获取系统自带的浏览器(如下代码操作)

Intent intent=new Intent();
intent.setAction("android.intent.action.VIEW");
Uri CONTENT_URI_BROWSERS = Uri.parse("http://static.nightpalace.cn/1496994313215");
intent.setData(CONTENT_URI_BROWSERS);
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
startActivity(intent);

2.选择手机带的浏览器(带有选择性的)
Intent intent1= new Intent();
intent1.setAction(Intent.ACTION_VIEW);
Uri content_url = Uri.parse("http://static.nightpalace.cn/1496994313215");
intent1.setData(content_url);
startActivity(Intent.createChooser(intent1,getString(R.string.about_cherry_choice_browser)));