从另一个应用程序启动firefox mobile

时间:2012-06-14 22:20:37

标签: android firefox fennec

我需要在我的应用程序中启动firefox mobile。我现在正在这样做:

String url = "http://www.google.it";
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName("org.mozilla.firefox_beta",
    "org.mozilla.firefox_beta.App"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse(url));
startActivity(intent);

如果firefox没有运行它会起作用。 如果它正在运行(在后台暂停),这段代码只会启动firefox而不加载我在代码中指定的url。

2 个答案:

答案 0 :(得分:7)

这对我有用:

adb shell am start -a android.intent.action.VIEW -n org.mozilla.firefox_beta/.App -d 'http://www.mozilla.org'

尝试更改您的:

Intent intent = new Intent(Intent.ACTION_MAIN, null);

Intent intent = new Intent(Intent.ACTION_VIEW, null);

答案 1 :(得分:0)

尝试:

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");
Bundle b = new Bundle();
b.putBoolean("new_window", true);
intent.putExtras(b);
intent.setData(Uri.parse(url));

我不确定这适用于firefox应用程序,但可能会有类似的东西。