2011-11-04 111 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); 
相关问题