Вопрос

I've developed an Android Application. I've defined an intent-filter so that my app is used to view some links:

<intent-filter>
            <data
                android:host="my_url.com"
                android:pathPrefix="/some_prefix/"
                android:scheme="http" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

When I open one link like "my_url.com/some_prefix", my app appears on the selector and, if chosen, its open to display the link.

However, my Activity is opened attached to the application that lauched it. Lets say, for example, that the link is displayed in a WhatsApp message, after opening the link my app is displayed. If I try to open WhatsApp again, my Activity is displayed, instead of WhatsApp.

How can I detach my Application from the Application that called it?

Это было полезно?

Решение

Your activity is being opened in the current 'task', which is the WhatsApp task.

What you are wanting is for your app to be opened in a new task.

There is a flag you can set on your activity in the manifest:

android:launchMode="singleTask"

This will tell android to open your activity in another task.

Read more about tasks here

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top