2

I created a basic Android app from the Eclipse wizard. I then added the following intent filter to AndroidManifest.xml, after the existing one. This makes it support a custom "sample://" URL scheme:

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

If I run Chrome or the default browser, and click a "sample://" link, it launches my app. However, if I look at the task switcher, my app isn't listed. Instead, Chrome is shown, with my app's screen shot.

Why is this? Can it be fixed? I'm running Android 4.2.2 on a Galaxy Nexus phone.

I notice that if I add android:launchMode="singleInstance" to the activity, it opens in a separate app. But the docs say this is "not recommended for general use". Why not?

1 Answer 1

7

The reason why you Activity appears in Recent Apps as Chrome is because it now belongs to the Chrome task, because it was launched from there.

As you noticed android:launchMode="singleInstance" solves your problem, however it is not recommended or discouraged because it would brake the user experience and navigation and how users expect your application to behave.

Fortunately, I think there's a way of specifying Intent flags in your HREF, try something like this:

<A HREF="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=com.example.package/.MyActivity;end" /> 

in the previous example launchFlags=FLAG_ACTIVITY_NEW_TASK. This flag is generally used by activities that want to present a "launcher" style behavior: they give the user a list of separate things that can be done, which otherwise run completely independently of the activity launching them.

Sign up to request clarification or add additional context in comments.

1 Comment

Really? Wouldn't you expect that if you launched an app from a URL, you could switch back and forth between that app and your browser, just as if you had manually launched the app? Maybe I'm more used to the iPhone UX, but this seems strange.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.