- Home /
Why does onDestroy in UnityPlayerActivity kill the entire process (Android)
I have an Android project which has one Unity activity embedded in it. I'm running into an issue where calling finish() from within this activity causes the entire process to be killed (it sends signal 9 -- SIGKILL). I've managed to pin it down to the call to super.onDestroy() in my Unity activity, which seems to suggest that UnityPlayerActivity kills the entire process in onDestroy(). I have to call through to super.onDestroy(), otherwise Android complains.
Is there a way to avoid this, or a good workaround I can use? Is it possible to override the UnityPlayerActivity onDestroy() function somehow?
Even more specifically, the signal 9 is co$$anonymous$$g from UnityPlayer.quit(). I've managed to work around this, but it's messing with my Activity stack a lot, so having some sort of cleanup function on UnityPlayer that didn't kill the entire process would be awesome. Does anybody know if there is such a function?
Answer by drdemon · Jul 20, 2013 at 07:48 AM
I was having same problem. I just found a workaround for this. You can start the Unity activties in a different process than the main one in your app. For this you will have to add following in your manifest for all the Unity activities (in my case UnityPlayerProxyActivity, UnityPlayerActivity, UnityPlayerNativeActivity).
android:process=":some_name_for_process"
(observe the ":" in the name. it is required)
Also if you are accessing any shared preferences in unity code, you will have to manipulated them with "MODE_MULTI_PROCESS" mode.
Answer by dttngan91 · Feb 22, 2014 at 06:27 AM
After time searching around, I found the solution for avoiding kill process in UnityPlayerActivity when we call finish(); In Activity extends UnityPlayerActivity, you should override onPause method and call super.onDestroy() on it instead of super.onPause(). Have a nice day!
Your answer
Follow this Question
Related Questions
Embedding unity into existing android app: UnityPlayer.quit kills app process 0 Answers
Android Unity, Screen Recording and MediaProjection APIs - UnityPlayerActivity hang. 0 Answers
How to open transparent activity from UnityPlayerActivity? 0 Answers
Android - Touch input won't work, Invisible activity in front of Unity activity 0 Answers
How to start the UnityPlayerActivity from a java plugin that overrides the basic Android Activity 1 Answer