AndroidRuntimePermissions helps you query/request runtime permissions synchronously on Android M and later. It also works on older Android versions and detects whether a requested permission is declared in AndroidManifest or not.
I never got a “permission box” on android and keep getting “Denied”.
Is the code right? can you add an example how to do it right?
Thanks again .
Dror
Yes your code is correct. Though, you can directly Debug.Log the result of RequestPermission. So, CheckPermission is redundant here.
For runtime permissions to work correctly, you have to declare the permission in AndroidManifest first. For WRITE_EXTERNAL_STORAGE, this can be achieved by setting Write Permission to External (SDCard) in Player Settings.
As you suggested I went to the player setting and changed the “Write Permission” to “External (SDCard)”, and still no Permission popup and the debug show “Denied”.
Can you assume the reason?
After building your project to Android, can you check the contents of PROJECT_PATH/Temp/StagingArea/AndroidManifest.xml and see if android:maxSdkVersion=“18” is still there? If so, try removing that part from your manifest. It basically adds WRITE_EXTERNAL_STORAGE permission to devices with API version less than or equal to 18. So, if your device has a newer Android version, it won’t have WRITE_EXTERNAL_STORAGE permission. BTW, may I ask your Android version?
P.S. Also check Settings/YOUR_APP/Permissions to see if Storage permission is available there.
Ok, finally things are starting to happen.
I removed the "android:maxSdkVersion=“18” from the manifest in the SDK
And now permission is Granted! Will I have a side effects from removing that line?
I still cant save my screenshot into my phone , but at list now I know I have permission :-).
p.s - I have Android version 8.0.0
Other than adding a “Storage: Modify or delete the contents of your USB storage” permission description to your permissions list in Google Play, there won’t be any side effects.
If your app saves screenshots to a public directory like Gallery, then you have to have WRITE_EXTERNAL_STORAGE permission no matter which API it is, so you should be good to go. But if your app saves the screenshots to a private directory like Application.temporaryCachePath, then you won’t be needing WRITE_EXTERNAL_STORAGE permission for this.
Hello, I am trying to get coarse gps for a lwp made with uLiveWallpaper. I get this when the Check for permissions is called:
AndroidJavaException: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Context.checkSelfPermission(java.lang.String)' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Context.checkSelfPermission(java.lang.String)' on a null object reference
Thank you for your prompt reply!
I got curious and checked how Google has their Earth LWP since I know it uses the gps. They call it on the preview activity so I image you can’t call it from the wallpaper service. I was able to quickly write a call for the gps on the preview activity.
Excuse me. For Some reason asking for Camera Permission also asking to access multimedia files in the device, which is odd, and I was wondering if it is a common occurence
Any clues?
But now this code Debug.Log("Permission" + AndroidRuntimePermissions.CheckPermission("android.permission.READ_EXTERNAL_STORAGE"));
just always returns denied
I think the SkipPermissionDialog option just skip dialog any time and not only on app start, but how to make it correctly?