I am trying to open the System Settings from my Unity Android app, but I am receiving the following error:
UnityEngine.AndroidJavaException: android.content.ActivityNotFoundException: No Activity found to handle Intent {act =android.settings.ACTION_SETTINGS cat=[android.intent.category.DEFAULT] dat=package:com.xxx.xxxxx flg=0x10000000}
Here is my code:
try
{
using (var unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
using (AndroidJavaObject currentActivityObject = unityClass.GetStatic<AndroidJavaObject>("currentActivity"))
{
string packageName = currentActivityObject.Call<string>("getPackageName");
using (var uriClass = new AndroidJavaClass("android.net.Uri"))
using (AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("fromParts", "package", packageName, null))
using (var intentObject = new AndroidJavaObject("android.content.Intent", "android.settings.ACTION_SETTINGS", uriObject))
{
intentObject.Call<AndroidJavaObject>("addCategory", "android.intent.category.DEFAULT");
intentObject.Call<AndroidJavaObject>("setFlags", 0x10000000);
currentActivityObject.Call("startActivity", intentObject);
}
}
}
catch (Exception e)
{
Debug.Log(e);
}
(Remove ACTION_)changed:android.settings.SETTINGS
User contributions licensed under CC BY-SA 3.0