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?

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.

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!

thanks @drdemon you are a genius

So happy to find your answer,definitely solved my problem!!thanks :smiley: @drdemon