How to redirect user from Unity game to system settings for this application, namely permission settings?
Starting from Android 6.0 Marshmallow (API level 23) developer should provide standard flow for asking dangerous permissions in run time. In case of “Don’t ask again” option has been selected, guideline suggests redirecting user to standard settings.
Hi,
I’ve been trying to use this in my app and although it works(the user is redirected to app settings) the application immediately crashes(with the message “Unfortunately, the app has stopped”), any ideas why it could be? Maybe i need to declare the intent in the manifest first?
i tried adding this intent
to the com.unity3d.player.UnityPlayerActivity activity in the android manifest. didn’t work.
Hello sir! I Just saw your post about redirecting into App Settings. Can you please help me about that thing? I Cant find some of API for redirecting into Wifi Settings. i Hope you can help me for that thing Thanks a lot si
First answer suggests this variant: startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
Probably it is worth trying to translate from Java to Unity proxies.
I Tried it Already sir. But When i run the app nothing happens sir. This is my code
var UnityPlayer = new AndroidJavaClass(“com.unity3d.player.UnityPlayer”);
var currentActivity = UnityPlayer.GetStatic(“currentActivity”);
var cn = currentActivity.Call(“ComponentName”,“com.android.settings”,“com.android.settings.wifi.WifiSettings”);
var intent = currentActivity.Call(“getIntent”);
This constant Settings.ACTION_WIFI_SETTINGS is equal to string “android.settings.WIFI_SETTINGS”, so we pass this value as literal:
using (var unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
using (AndroidJavaObject currentActivityObject =
unityClass.GetStatic<AndroidJavaObject>("currentActivity"))
using (var intentObject = new AndroidJavaObject(
"android.content.Intent", "android.settings.WIFI_SETTINGS"))
{
currentActivityObject.Call("startActivity", intentObject);
}
I am trying to start google play paywall from unity app and it is giving me an error that “Java.lang.ClassNotFoundException: android.intent.action.VIEW”
try
{
//Application.OpenURL(m_LicensingURL_Received);
using (var activity = m_Activity)
using (var uriClass = new AndroidJavaClass("android.net.Uri"))
using (var uri = uriClass.CallStatic<AndroidJavaObject>("parse", m_LicensingURL_Received))
using (var paywallIntent = new AndroidJavaObject("android.intent.action.VIEW", uri))
using (paywallIntent.Call<AndroidJavaObject>("setPackage", "com.android.vending" /*Play Store */))
{
activity.Call("startActivity", paywallIntent);
}
}
catch (Exception e)
{
Debug.LogError("Exception "+ e);
}
Hey guys,
So the above code had been working for me on the Quest 1 headset (Android 7), but it no longer works on the Quest 2 headset (Android 10).
I’ve been searching for a week now trying to find an answer about why this is broken and how to correctly pull up the app settings for the user… Does anyone have any idea on what needs to happen for this to work for Android v10?
try {
using (var unityPlayer = new AndroidJavaClass(“com.unity3d.player.UnityPlayer”))
using (var activity = unityPlayer.GetStatic(“currentActivity”))
using (var uriClass = new AndroidJavaClass(“android.net.Uri”))
using (var uri = uriClass.CallStatic(“parse”, m_LicensingURL_Received))
using (var paywallIntent = new AndroidJavaObject(“android.content.Intent”, “android.intent.action.VIEW”, uri))
using (paywallIntent.Call(“setPackage”, “com.android.vending”)) {
activity.Call(“startActivity”, paywallIntent);
}
} catch (Exception e) {
Debug.LogError(e.ToString());
}