我正在尝试从Unity Android应用打开系统设置,但收到以下错误:
UnityEngine.AndroidJavaException: android.content.ActivityNotFoundException:未找到要处理的活动 意图{act = android.settings.ACTION_SETTINGS cat = [android.intent.category.DEFAULT] dat = package:com.xxx.xxxxx flg = 0x10000000}
这是我的代码:
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);
}
答案 0 :(得分:0)
(删除ACTION_)已更改:android.settings.SETTINGS