1

I have successfully set up an intent-filter in my Android app to open the app from the mobile browser based on one of many SO posts on this topic.

However, the problem is that the native app is opening WITHIN the browser, when I rather want it to open OUTSIDE of the browser in a separate app process.

By WITHIN, I mean that when I press the rightmost 'active apps' button to see what is running, I see that my current app is still the browser app, and there is no separate app opened called MyApp. It is as if the browser embeds my native app within itself, and so the browser is executing my app process.

And by OUTSIDE, I mean that I want to be able to see two active apps running after I press the link: (1) the browser app from which I launched (2) my MyApp app.

This is my intent-filter set up in AndroidManifest.xml:

<intent-filter>
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <action android:name="android.intent.action.VIEW" />

    <data android:scheme="myapp" android:host="mypath" />
</intent-filter>

And I link to this from a web page opened in the browser using:

<a href="myapp://mypath">Open app</a>

How can I force the app to open OUTSIDE of the browser? One note is that when the app launches I don't see an 'app chooser' which I've seen for other apps.

Community
  • 1
  • 1
Ryan
  • 539
  • 1
  • 5
  • 14
  • "the problem is that the native app is opening WITHIN the browser" -- please explain **in detail** what you mean by this. "I rather want it to open OUTSIDE of the browser in a separate app process" -- your app is running in its own process. It always does. "How can I force the app to open OUTSIDE of the browser?" -- please explain **in detail** what you mean by this. – CommonsWare Feb 19 '17 at 00:05
  • I added more detail, as requested. Additions copied here for you to read directly. By WITHIN, I mean that when I press the rightmost 'active apps' button to see what is running, I see that my current app is still the browser app, and there is no separate app opened called MyApp. It is as if the browser embeds my native app within itself, and so the browser is executing my app process. And by OUTSIDE, I mean that I want to be able to see two active apps running after I press the link: (1) the browser app from which I launched (2) my MyApp app. – Ryan Feb 19 '17 at 00:13

1 Answers1

3

By WITHIN, I mean that when I press the rightmost 'active apps' button to see what is running, I see that my current app is still the browser app, and there is no separate app opened called MyApp.

Your activity was launched within the browser's task.

It is as if the browser embeds my native app within itself and itself is executing my app process.

That is not what is happening.

How can I force the app to open OUTSIDE of the browser?

If you mean that you want the activity to appear in a separate task... ideally, that would happen by default. I'm surprised that a browser would not have added FLAG_ACTIVITY_NEW_TASK when it started your activity.

That being said, android:launchMode="singleTask" on your <activity> element should give you the desired behavior.

CommonsWare
  • 910,778
  • 176
  • 2,215
  • 2,253
  • Thank you so very much! I agree that it is odd that by default the launch mode is not set to open as a new task. And yeah, as for my embedded process comment, I was unaware of the concept of 'tasks' and so was using 'processes' to describe what in fact are tasks. Again - much appreciated. – Ryan Feb 19 '17 at 00:19
  • @Ryan: If you don't mind my asking -- what browser are you testing with? Chrome? – CommonsWare Feb 19 '17 at 00:24
  • No, not Chrome because the emulator instances that I am running don't have it. I am using what I assume is just a simple base Android browser (called "Browser" in the apps list - icon shown here http://androidpicks.com/download-lollipop-browser-apk-5-1/) – Ryan Feb 19 '17 at 00:32