系統上安裝了多種瀏覽器,能否指定某瀏覽器訪問指定頁面?請說明原由。

一、啓動android默認瀏覽器
在Android程序中我們可以通過發送隱式Intent來啓動系統默認的瀏覽器。如果手機本身安裝了多個瀏覽器而又沒有設置默認瀏覽器的話,系統將讓用戶選擇使用哪個瀏覽器來打開連接。關於Intent的更多內容請參考《常用Intent
示例1

 

        Intent intent =newIntent();
        intent.setAction("android.intent.action.VIEW");
        Uri content_url =Uri.parse("http://www.163.com");
        intent.setData(content_url);
        startActivity(intent);
這樣子,android就可以調用起手機默認的瀏覽器訪問。
二、啓動指定瀏覽器
在Android程序中我們可以通過發送顯式Intent來啓動指定的瀏覽器。
啓動Android原生瀏覽器
示例2

 

         Intent intent =newIntent();        
         intent.setAction("android.intent.action.VIEW");    
         Uri content_url =Uri.parse("http://www.163.com");   
         intent.setData(content_url);           
         intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");   
         startActivity(intent);
只要修改以intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
中相應的應用程序packagename 和要啓動的activity即可啓動其他瀏覽器來
uc瀏覽器""com.uc.browser", "com.uc.browser.ActivityUpdate
opera瀏覽器:"com.opera.mini.android", "com.opera.mini.android.Browser"
qq瀏覽器:"com.tencent.mtt", "com.tencent.mtt.MainActivity"
發佈了16 篇原創文章 · 獲贊 7 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章