Android back button (706712)

Hello,

I’m getting mad to proper map and use de back button of android. I tried 3 codes that I found on the web and nothing. Any help?

public class RrAndroidBackButton : MonoBehaviour {

    public static RrAndroidBackButton instance;

    void Awake() {
        if (null == instance) {
            instance = this;
            DontDestroyOnLoad(this.gameObject);
        } else {
            Destroy(gameObject);
        }
    }

    void FiexdUpdate () {
        if (Application.platform == RuntimePlatform.Android){
            if (Input.GetKey(KeyCode.Escape)) {
                Application.Quit();

                System.Diagnostics.Process.GetCurrentProcess().Kill();

                AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer")
                        .GetStatic<AndroidJavaObject>("currentActivity");
                activity.Call<bool>("moveTaskToBack", true);
            }
        }
    }
}

You have a mistake in the method name. “FiexdUpdate” should be “FixedUpdate”. Although just “Update” would be fine as well.

1 Like