Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by MihajloNen · Sep 11, 2017 at 01:20 PM · androidpluginandroid sdkandroid-manifestpermissions

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

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image emathew · Dec 04, 2017 at 06:38 PM 0
Share

Have you figured out a solution to your problem? I am having the same issue.

avatar image MihajloNen emathew · Dec 06, 2017 at 07:51 PM 0
Share

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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

146 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android Manifest with Single Permission 2 Answers

Android Permissions API Version 1 Answer

I can't use TTS on Android 11 1 Answer

Removing unecessary permissions from AndroidManifest that Unity+Plugins put in there? 0 Answers

how can i integrate applovin and chartboost for android 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges