Android 打开URL

打开链接

<span style="white-space:pre">	</span>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);  

打开本地网页

<span style="white-space:pre"></span><ol start="1" class="dp-j" style="margin: 0px; padding: 5px 0px; border: none; position: relative; list-style-position: initial; list-style-image: initial; color: rgb(92, 92, 92); font-family: Consolas, 'Courier New', Courier, mono, serif; line-height: 26px;"><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border: none; list-style: decimal-leading-zero outside; color: inherit; line-height: 13.1999998092651px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"><span style="white-space:pre">	</span>Intent intent=</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 0, 255); font-weight: bold; background-color: inherit;">new</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> Intent();   </span></span></li><li style="border: none; list-style: decimal-leading-zero outside; line-height: 13.1999998092651px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span style="white-space:pre">	</span>intent.setAction(<span class="string" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 153, 0); background-color: inherit;">"android.intent.action.VIEW"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);   </span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border: none; list-style: decimal-leading-zero outside; color: inherit; line-height: 13.1999998092651px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span style="white-space:pre">	</span>Uri CONTENT_URI_BROWSERS = Uri.parse(<span class="string" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 153, 0); background-color: inherit;">"content://com.android.htmlfileprovider/sdcard/123.html"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);   </span></span></li><li style="border: none; list-style: decimal-leading-zero outside; line-height: 13.1999998092651px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span style="white-space:pre">	</span>intent.setData(CONTENT_URI_BROWSERS);   </span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border: none; list-style: decimal-leading-zero outside; color: inherit; line-height: 13.1999998092651px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span style="white-space:pre">	</span>intent.setClassName(<span class="string" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 153, 0); background-color: inherit;">"com.android.browser"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">, </span><span class="string" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 153, 0); background-color: inherit;">"com.android.browser.BrowserActivity"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);   </span></span></li><li style="border: none; list-style: decimal-leading-zero outside; line-height: 13.1999998092651px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span style="white-space:pre">	</span>startActivity(intent);  </span></li></ol>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值