- Home /
How to keep other activities on top after pressing the home button on Android?
Let's say you're using some plugins that pop up other activities (as part of the same task), such as ad providers. You're watching an ad on this other activity, and you press the home button and then relaunch the Unity app. Now, because Unity runs in "SingleTask" mode, all other activities on top get destroyed, and the default unity player view gets destroyed.
The main problem is that a lot of ad providers don't handle this scenario, and end up in weird buggy states if that happens (including Everyplay/UnityAds). They usually become unable to display ads afterwards, and don't give the proper callbacks so it might freeze Unity.
How can I make it so that the second activity doesn't get destroyed when pressing the home button? Or how do you deal with this issue?
What I've tried:
exporting an Eclipse project and setting the app to SingleTop instead. This gives a black screen.
"singleTop" plus making the second instance of the unity activity get destroyed if it is not the root activity. This indeed shows the ad provider activity, but when I go back to the unity activity it restarts if it gets a new intent (aka if you open it once from the play store, and then from the dashboard)
"singleTop" plus bypassing the UnityPlayerNativeActivity(http://bit.ly/1A9QqNb) by creating a class that does the same thing if it is the root activity, and if it is not the root activity it returns without initialising or doing anything to UnityPlayer. This gives an internal segfault a short while after returning in the app.
Any other ideas? Thanks for reading.
The scenario you describe is not accurate - it will only happen in case you are in the second launched activity (ad), press the HO$$anonymous$$E button and then return to Unity from it's launcher icon (it is O$$anonymous$$ if you return to it from the recent apps list).