1

Actually I have an Android App in which I run my Unity3D game. Everything works well together. Now, when I launch Unity inside my app the game starts normally but if I try to go back to my AndroidApp intent I received a "SIGNAL 11 SIGSEGV" and Unity just close.

This happens when I'm drawing a Menu inside Unity and press "Exit" button to close Unity but if I do the same with the Android back buton Unity closes normally without problems.

I'm using plugins in Unity to achieve this behaviour.

My Function in Unity Side :

public void ExitGame()
{
    #if UNITY_ANDROID
    AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"); 
    AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity");      
    activity.Call ("ReturnToMainActivity", "Hello");
    #endif
}

Function in Android Side :

public void ReturnToMainActivity (String someText)
{
    Log.v("Unity", "Finish Unity from Android" );
    this.mUnityPlayer.quit();
    UnityPlayer.currentActivity.finish();
}

Again, this works normally if I press the Android Back Button inside Unity app but when I try to do the same with an Unity GUI.Button I received a "SIGNAL 11 SIGSEGV". In Both Cases logcat print the message "Finish Unity from Android" so I think Unity calls the function normally but in some Point just crashes.

Someone post faced the same problem but I can't figure out how he solve it.

SIGNAL 11 SIGSEGV crash Android

Community
  • 1
  • 1

1 Answers1

0

Ok, I just figure out how to do this.

In my function inside Android Side:

public void ReturnToMainActivity (String someText)
{
    UnityPlayer.currentActivity.runOnUiThread(new Runnable(){
        public void run()
        {
            Log.v("Unity", "Aplicacion de Unity terminada desde Android" );
            ElJuegoActivity.this.mUnityPlayer.quit();
            UnityPlayer.currentActivity.finish();
        }
    });
}

And that does the trick. No issues or problems.


NOTE: This is the "answer" the OP originally included at the end of his question. I've separated it into its own CW answer. If the OP returns and wants to post it himself, by all means ping me

Bart
  • 19,692
  • 7
  • 68
  • 77