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);
}
}
}
}