2011-11-04 138 views
6

只是想知道是否有人知道啓動Firefox的移動瀏覽器的正確意圖。我無法在任何地方找到它,所以我希望這裏有人知道。 感謝Android:從應用程序內啓動Firefox

+0

爲什麼Firefox的具體?爲什麼不是一般的「瀏覽器」意圖?如果用戶沒有FF,該怎麼辦? –

+0

你不能啓動瀏覽器嗎?如果您將Firefox設置爲默認瀏覽器,則手機應該啓動。 – omermuhammed

+0

這是一款商業銷售應用程序,因此它們將始終使用相同的瀏覽器在同一臺平板電腦上運行。現在我有瀏覽器選擇器出現,但這有點煩人,我想稍微精簡一下。 – Leonidas

回答

8

這將創建一個用於Firefox的意圖:

String url = "http://example.com/"; 
Intent intent = new Intent(Intent.ACTION_MAIN, null); 
intent.addCategory(Intent.CATEGORY_LAUNCHER); 
intent.setComponent(new ComponentName("org.mozilla.firefox", "org.mozilla.firefox.App")); 
intent.setAction("org.mozilla.gecko.BOOKMARK"); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
intent.putExtra("args", "--url=" + url) 
intent.setData(Uri.parse(url)); 
+0

謝謝。我不需要再啓動Firefox了,但是這個工作正常! – Leonidas

3

試試這個代碼:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 
intent.setComponent(new ComponentName("org.mozilla.firefox", "org.mozilla.firefox.App")); 
this.startActivity(intent); 
相關問題