Google Files not respecting singleInstance launchMode

26 Views Asked by At

My main Activity is defined as follows:

<activity
    android:name="com.bjornfelle.redacted.MainActivity"
    android:exported="true"
    android:launchMode="singleInstance">

I also have an intent filter for importing images as follows:

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
</intent-filter>

If I share an image with my app from a third party file manager, say CxFileExplorer, it switches to the currently running instance of my app if any, or launches it if not. This is desired behaviour.

If I do the same thing but share the file from Google Files, a new instance of my app is spawned within Google Files regardless of whether or not it is already running. This breaks things with my app and is not the desired behaviour.

If I remove android:launchMode="singleInstance" from my Activity definition, even CxFileExplorer spawns an additional instance of the app if it's already running. So I know this flag is doing something, it just seems that Google Files is not respecting it. Is there something else I can do to prevent this behaviour so that the app will truly be single instance, or do I need to code around this?

0

There are 0 best solutions below