天天看点

activity android:launchmode,unity3d - Setting android:launchmode for UnityPlayerActivity - Stack Ove...

I'm building an Android game on Unity which has a button that opens a new activity.

The problem is when building the APK, no matter what I put in my custom AndroidManifest.xml, Unity overrides it and sets android:launchMode for com.unity3d.player.UnityPlayerActivity to singleTask.

This results in the following scenario: Open the game, tap the button that opens the activity, tap the home button to go to background, relaunch the app using the icon - the new activity is destroyed and instead I see the same main UnityPlayerActivity (it's the same original one - nothing has been recreated).

In order to fix it - I had to create the apk, decompile it using apktool, hardcode android:launchMode=0 for com.unity3d.player.UnityPlayerActivity (which means standard instead of singleTask), recompile it, resign it, and only then install it.

This is obviously a total hack and can't be used as an actual solution. I need to find a way to set the android:launchMode myself.

How can I do that?