Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
CloseIndicates the Java instance of the current context.
For more information, refer to the Android developer documentation on Context.
Note: This object is managed by Unity runtime, so do not call AndroidJavaObject.Dispose on it.
using UnityEngine; using UnityEngine.Android;
public class Controller : MonoBehaviour { void Start() { var isRunningGameActivity = AndroidApplication.currentContext.Call<string>("getLocalClassName").Equals("com.unity3d.player.UnityPlayerGameActivity"); var isRunningActivity = AndroidApplication.currentContext.Call<string>("getLocalClassName").Equals("com.unity3d.player.UnityPlayerActivity"); Debug.Log($"GameActivity {isRunningGameActivity}"); Debug.Log($"Activity {isRunningActivity}"); } }