- Home /
 
How to check if user has given camera or location permissions (android)
I really struggle with this since a while :( I need to check if the user has given the permission to access the Android device camera (and location on a second level).
Normally the app start by asking for this permissions at launch, but if the user denies the access for the camera I need to know and check that later.
Otherwise the user could hit the camera UI button I made and try to access the camera via webcamtexture... and that leads into a crash of the app.
Since Android API 23 you cannot ignore or already grant permissions by changing the android manifest like I tried after reading several posts about that.
Thank's to everyone who has an idea to solve this
Have you figured out a solution to your problem? I am having the same issue.
hi @emathew, I solved it with a Plugin. Check therefor the following Unity Page: Native Plugins Unity
and here's my part of the code I used to get to check the camera permission:
 using System.Collections;
 using UnityEngine;
 using System.Runtime.InteropServices;
 
 
 public class PermissionCheckerScript 
 
 
 
 {
 
     [DllImport ("__Internal")] extern static private void sd_camera_permission();
 
     public static void CameraAuthorization()
     {
         sd_camera_permission();
     }
 
     [DllImport ("__Internal")] private static extern bool getCameraStatus ();
 
     public static void CamPermStatusReader()
     {
         getCameraStatus ();
     }
     public static void CamPermValidation()
     {
         
         if (getCameraStatus()) 
         {
             $$anonymous$$ailerScript.camAcessGiven = true;
             Debug.Log ("camstatus = true");
         } 
         else if(!getCameraStatus())
         {
             $$anonymous$$ailerScript.camAcessGiven = false;
             Debug.Log ("camstatus = false");
         }
 
     }
 
     [DllImport ("__Internal")] private static extern void go_to_appsettings();
 
     public static void GoToAppSettings()
     {
         go_to_appsettings ();
     }
 }
 
                   ...the functions can be called when needed to check the permissions
Your answer