Reputation: 1
Right now the user is being send to setting to switch on GPS manually. I want the location to be enabled inside the app, no manually.
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext");
AndroidJavaObject locationManager = context.Call<AndroidJavaObject>("getSystemService", "location");
if (locationManager != null)
{
AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent", "android.settings.LOCATION_SOURCE_SETTINGS");
currentActivity.Call("startActivity", intent);
}
Upvotes: 0
Views: 54