2
\$\begingroup\$

I am trying to rout from my unity application to android app settings permissions. till now I achieved to rout to app settings, But i want to take 1 step more to go inside permission i mean App Settings > Permissions.

Code:

try
        {
#if UNITY_ANDROID
            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.APPLICATION_DETAILS_SETTINGS", uriObject))
                {
                    intentObject.Call<AndroidJavaObject>("addCategory", "android.intent.category.DEFAULT");
                    intentObject.Call<AndroidJavaObject>("setFlags", 0x10000000);
                    currentActivityObject.Call("startActivity", intentObject);
                }
            }
#endif
        }
        catch (System.Exception ex)
        {
            Debug.LogException(ex);
        }

Help if it is possible... any help is appropriated. Thank in advance.

\$\endgroup\$
  • \$\begingroup\$ Not really an answer to your question, but doesn't android automatically handle permissions now, every time an app requests one? \$\endgroup\$ – TomTsagk Sep 25 '19 at 11:18
  • 1
    \$\begingroup\$ It does. Android do ask for permission and I've implemented the run time permissions and it works as intended. But there is spacial case if user Denies the permission with "Don't ask again" then unity will not be able to regenerate the permission so if user later want to access this feature then for user convenience I want to add "Go to Settings" button which will route user to permission settings of the app. I know its a rare case but still a possibility and I to cover this hole. \$\endgroup\$ – Swati Sep 25 '19 at 11:45
1
\$\begingroup\$

I don't think it's possible to open 'permissions' page directly from the app.

However you can open settings page with Toast like, "click permissions and allow X permission to proceed", to guide the user.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I think you are right... I have not found any official document which will explain "Permission" accessibility but from multiple places, I found that it is not allowed. And yes I already did what you have suggested but didn't use Toast instead i used a full panel with text and graphics on it. Anyway thanks for the help... \$\endgroup\$ – Swati Dec 9 '19 at 4:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.