简体   繁体   English

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

[英]Launch firefox mobile from another app

I need to launch firefox mobile within my application. 我需要在我的应用程序中启动firefox mobile。 I'm currently doing this: 我现在正在这样做:

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);

And it works if firefox is not running. 如果firefox没有运行它会起作用。 While if it is running (paused in background) this code just bring firefox up without loading the url I specified in the code. 如果它正在运行(在后台暂停),这段代码只需启动firefox而不加载我在代码中指定的url。

This works for me: 这对我有用:

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

Try changing your: 尝试更改你的:

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

to

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

try: 尝试:

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));

I'm not sure this will work for the firefox app, but there may be something similar. 我不确定这适用于firefox应用程序,但可能有类似的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM