Since there is currently no native support for the new permission system in Android 6.0 Marshmallow I wrote a little class for it.
How to use this:
- This Class needs the Phone and the JavaObject Library
- Set the targetSdkVersion in your manifest to at least 23
- Add the permission you want to request to your Manifest
- Put the following code in your project:
Update Nov 10 2015:
- Added option to show rationale
- Added a simple sample project
Update Mar 14 2016:
- CheckPermission returns alsways "True" when SDK Version < 23
How to use this:
- This Class needs the Phone and the JavaObject Library
- Set the targetSdkVersion in your manifest to at least 23
- Add the permission you want to request to your Manifest
- Put the following code in your project:
B4X:
Sub Globals
Private Permission As Mpermission
End Sub
Sub Activity_Create(FirstTime As Boolean)
Permission.Initialize
If Permission.CheckPermission ("android.permission.CAMERA") = False Then
Permission.RequestPermission ("android.permission.CAMERA")
End If
End Sub
Update Nov 10 2015:
- Added option to show rationale
- Added a simple sample project
Update Mar 14 2016:
- CheckPermission returns alsways "True" when SDK Version < 23
Attachments
Last edited: