【開發技能】Android調用瀏覽器的兩種方式

1.調用默認瀏覽器並直接打開
web

[AppleScript]   純文本查看   複製代碼
?
1
2
3
Uri uri = Uri.parse ( url ) ;
Intent intent = new Intent ( Intent.ACTION_VIEW , uri ) ;
startActivity ( intent ) ;



2.彈出一個選擇瀏覽器的框,選擇瀏覽器再進入:
瀏覽器

[AppleScript]   純文本查看   複製代碼
?
1
2
3
4
5
Intent intent = new Intent ( ) ;
intent.setAction ( Intent.ACTION_VIEW ) ;
Uri content_url = Uri.parse ( url ) ;
intent.setData ( content_url ) ;
startActivity ( Intent.createChooser ( intent , 「請選擇一款瀏覽器」 ) ;
相關文章
相關標籤/搜索