3

I need to launch firefox mobile within my application. 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. While if it is running (paused in background) this code just bring firefox up without loading the url I specified in the code.

rops
  • 217
  • 3
  • 10

2 Answers2

8

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);
Mark Finkle
  • 966
  • 4
  • 5
0

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.

Sturm
  • 4,105
  • 3
  • 24
  • 39
  • 1
    sure..the thing is : if firefox is not running and I start a new activity the code above works and it loads the url I specified..while if firefox has been started before and it is just running in background it will just pop up showing the last opened page (without even reloading it cause it was just sent to background ) – rops Jun 14 '12 at 22:48
  • daniele: i am seeing the same behavior. Have you figured out any solution? – aslakjo Oct 21 '13 at 11:06