一、打开链接
Intent it = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com"));
it.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
getContext().startActivity(it);
二、打开本地网页
Intent intent=new Intent();
intent.setAction("android.intent.action.VIEW");
Uri CONTENT_URI_BROWSERS = Uri.parse("content://com.android.htmlfileprovider/sdcard/123.html");
intent.setData(CONTENT_URI_BROWSERS);
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
startActivity(intent);
本文介绍了两种在Android应用中打开网页的方式:一是通过Intent启动浏览器加载指定URL;二是加载本地HTML文件,涉及到使用Content URI定位文件及指定浏览器Activity。
578

被折叠的 条评论
为什么被折叠?



