- Home /
finish on UnityPlayerActivity kills the entire application
I have an Android project in which I have one Unity activity integrated in it. I'm running into an issue when i call finish() from within unity activity to return the main activity. It causes the entire process to be killed (it sends signal 9 -- SIGKILL).
This is how I call the java method that handles the back button from Unity C# code:
void Update ()
{
if (Input.GetKeyDown (KeyCode.Escape)) {
AndroidJavaClass jc = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject> ("currentActivity");
jo.Call ("goBack");
}
}
And I call finish from the Unity activity once I export my project as an Android project:
void goBack(){
finish();
}
Can you please post the logcat output for this scenario ? (e.g: when clicking back)
Answer by yacine.hebbal · Aug 25, 2014 at 11:44 AM
Finaly this code solved the problem:
public void goBack() {
Runnable action = new Runnable() {
@Override
public void run() {
onBackPressed();
}
};
runOnUiThread(action);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613161252im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Unity Ads Unnecessary Android Permissions 1 Answer
FATAL EXCEPTION - dvm crash ? 1 Answer
UnityPlayer quit is killing both itself and the Android app 0 Answers