B4A Library PermissionsManager

PermissionsManager is a library that enables the management of runtime permissions. This library completely replaces the standard RuntimePermissions library with the addition of modern dangerous permissions and special permissions that require approval via the settings application.

This library contains constants for:
  1. Dangerous permissions,
  2. Special permissions.

For both types of permissions, the request principle is the same and is performed via one of the CheckAndRequestPermission methods. Example:
Dangerous:
Dim PM As PermissionsManager
PM.CheckAndRequestPermission(PermissionsManager.DANGEROUS_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
'or
'Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result Then
    'Allowed
End If
Special:
Dim PM As PermissionsManager
PM.CheckAndRequestPermission(PermissionsManager.SPECIAL_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
'or
'Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result Then
    'Allowed
End If
Of course, all permissions must be declared in the manifest, either automatically or manually.

As of version 1.2, the PermissionsManagerFileProvider class is included in the library. This FileProvider reduces the size of the final application by 0.5MB compared to the standard B4A FileProvider. This is made possible by wrapping the FileProvider class from the androidx.core:core package.

As of version 1.3, the PermissionsManagerFileProvider class is replaced with FileProvider static class module (B4X module).

To use FileProvider add the following lines to the manifest:
Manifest::
AddApplicationText(
<provider
android:name="igolub.permissionmanager.b4a.PMFileProvider"
android:authorities="$PACKAGE$.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
)
CreateResource(xml, provider_paths,
<files-path name="name" path="shared" />
)

PermissionsManager
Author:
Ivica Golubovic
Version: 1.3
  • FileProvider
    Copy next lines to manifest:<code>
    AddApplicationText(
    <provider
    android:name="igolub.permissionmanager.b4a.PMFileProvider"
    android:authorities="$PACKAGE$.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
    android:name="android.support.FILE_PROVIDER_PATHS"
    android:resource="@xml/provider_paths"/>
    </provider>
    )
    CreateResource(xml, provider_paths,
    <files-path name="name" path="shared" />
    )
    </code>
    • Functions:
      • GetFileUri (FileName As String) As Object
      • SetFileUriAsIntentData (mIntent As Intent, FileName As String)
    • Properties:
      • SharedFolder As String [read only]
      • UseFileProvider As Boolean [read only]
  • PermissionsManager
    • Fields:
      • DANGEROUS_ACCEPT_HANDOVER As String
        Allows a calling application to continue a call which was started in another application. An example is a video calling application that wants to continue a voice call on the user's mobile network.
        Constant Value: "android.permission.ACCEPT_HANDOVER".
        Add line to manifest: <code>AddPermission("android.permission.ACCEPT_HANDOVER")</code>
        Added in API level 28.
      • DANGEROUS_ACCESS_BACKGROUND_LOCATION As String
        Allows an application To access location in the background. If you're requesting this permission, you must also request either ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION. Requesting this permission by itself doesn't give you location access.
        Constant Value: "android.permission.ACCESS_BACKGROUND_LOCATION".
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_BACKGROUND_LOCATION")</code>
        Added in API level 29..
      • DANGEROUS_ACCESS_COARSE_LOCATION As String
        Allows an application To access approximate location. Alternatively, you might want ACCESS_FINE_LOCATION.
        Constant Value: "android.permission.ACCESS_COARSE_LOCATION".
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_COARSE_LOCATION")</code>
        Added in API level 1.
      • DANGEROUS_ACCESS_FINE_LOCATION As String
        Allows an application to access precise location. Alternatively, you might want ACCESS_COARSE_LOCATION.
        Constant Value: "android.permission.ACCESS_FINE_LOCATION".
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_FINE_LOCATION")</code>
        Added in API level 1.
      • DANGEROUS_ACCESS_MEDIA_LOCATION As String
        Allows an application to access any geographic locations persisted in the user's shared collection.
        Constant Value: "android.permission.ACCESS_MEDIA_LOCATION".
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_MEDIA_LOCATION")</code>
        Added in API level 29.
      • DANGEROUS_ACTIVITY_RECOGNITION As String
        Allows an application to recognise physical activity.
        Constant Value: "android.permission.ACTIVITY_RECOGNITION".
        Add line to manifest: <code>AddPermission("android.permission.ACTIVITY_RECOGNITION")</code>
        Added in API level 29.
      • DANGEROUS_ADD_VOICEMAIL As String
        Allows an application to add voice mails into the system.
        Constant Value: "com.android.voicemail.permission.ADD_VOICEMAIL".
        Add line to manifest: <code>AddPermission("com.android.voicemail.permission.ADD_VOICEMAIL")</code>
        Added in API level 14.
      • DANGEROUS_ANSWER_PHONE_CALLS As String
        Allows the application to answer an incoming phone call.
        Constant Value: "android.permission.ANSWER_PHONE_CALLS".
        Add line to manifest: <code>AddPermission("android.permission.ANSWER_PHONE_CALLS")</code>
        Added in API level 26.
      • DANGEROUS_BLUETOOTH_ADVERTISE As String
        Required to be able to advertise to nearby Bluetooth devices.
        Constant Value: "android.permission.BLUETOOTH_ADVERTISE".
        Add line to manifest: <code>AddPermission("android.permission.BLUETOOTH_ADVERTISE")</code>
        Added in API level 31.
      • DANGEROUS_BLUETOOTH_CONNECT As String
        Required to be able to connect to paired Bluetooth devices.
        Constant Value: "android.permission.BLUETOOTH_CONNECT".
        Add line to manifest: <code>AddPermission("android.permission.BLUETOOTH_CONNECT")</code>
        Added in API level 31.
      • DANGEROUS_BLUETOOTH_SCAN As String
        Required to be able to discover and pair nearby Bluetooth devices.
        Constant Value: "android.permission.BLUETOOTH_SCAN".
        Add line to manifest: <code>AddPermission("android.permission.BLUETOOTH_SCAN")</code>
        Added in API level 31.
      • DANGEROUS_BODY_SENSORS As String
        Allows an application to access data from sensors that the user uses to measure what is happening inside their body, such as heart rate.
        Constant Value: "android.permission.BODY_SENSORS".
        Add line to manifest: <code>AddPermission("android.permission.BODY_SENSORS")</code>
        Added in API level 20.
      • DANGEROUS_BODY_SENSORS_BACKGROUND As String
        Allows an application to access data from sensors that the user uses to measure what is happening inside their body, such as heart rate. If you're requesting this permission, you must also request BODY_SENSORS. Requesting this permission by itself doesn't give you Body sensors access.
        Constant Value: "android.permission.BODY_SENSORS_BACKGROUND".
        Add line to manifest: <code>AddPermission("android.permission.BODY_SENSORS_BACKGROUND")</code>
        Added in API level 33.
      • DANGEROUS_CALL_PHONE As String
        Allows an application to initiate a phone call without going through the Dialler user interface for the user to confirm the call.
        Constant Value: "android.permission.CALL_PHONE".
        Add line to manifest: <code>AddPermission("android.permission.CALL_PHONE")</code>
        Added in API level 1.
      • DANGEROUS_CAMERA As String
        Required to be able to access the camera device. This will automatically enforce the uses-feature manifest element for all camera features. If you do not require all camera features or can properly operate if a camera is not available, then you must modify your manifest as appropriate in order to install on devices that don't support all camera features.
        Constant Value: "android.permission.CAMERA".
        Add line to manifest: <code>AddPermission("android.permission.CAMERA")</code>
        Added in API level 1.
      • DANGEROUS_GET_ACCOUNTS As String
        Allows access to the list of accounts in the Accounts Service.
        Constant Value: "android.permission.GET_ACCOUNTS".
        Add line to manifest: <code>AddPermission("android.permission.GET_ACCOUNTS")</code>
        Added in API level 1.
      • DANGEROUS_NEARBY_WIFI_DEVICES As String
        Required to be able to advertise and connect to nearby devices via Wi-Fi.
        Constant Value: "android.permission.NEARBY_WIFI_DEVICES".
        Add line to manifest: <code>AddPermission("android.permission.NEARBY_WIFI_DEVICES")</code>
        Added in API level 33.
      • DANGEROUS_POST_NOTIFICATIONS As String
        Allows an application to post notifications.
        Constant Value: "android.permission.POST_NOTIFICATIONS".
        Add line to manifest: <code>AddPermission("android.permission.POST_NOTIFICATIONS")</code>
        Added in API level 33.
      • DANGEROUS_PROCESS_OUTGOING_CALLS As String
        Allows an application to see the number being dialled during an outgoing call with the option to redirect the call to a different number or abort the call altogether.
        Constant Value: "android.permission.PROCESS_OUTGOING_CALLS".
        Add line to manifest: <code>AddPermission("android.permission.PROCESS_OUTGOING_CALLS")</code>
        Added in API level 1.
        Deprecated in API level 29.
      • DANGEROUS_READ_CALENDAR As String
        Allows an application to read the user's calendar data.
        Constant Value: "android.permission.READ_CALENDAR".
        Add line to manifest: <code>AddPermission("android.permission.READ_CALENDAR")</code>
        Added in API level 1.
      • DANGEROUS_READ_CALL_LOG As String
        Allows an application to read the user's call log.
        Constant Value: "android.permission.READ_CALL_LOG".
        Add line to manifest: <code>AddPermission("android.permission.READ_CALL_LOG")</code>
        Added in API level 16.
      • DANGEROUS_READ_CONTACTS As String
        Allows an application to read the user's contacts data.
        Constant Value: "android.permission.READ_CONTACTS".
        Add line to manifest: <code>AddPermission("android.permission.READ_CONTACTS")</code>
        Added in API level 1.
      • DANGEROUS_READ_EXTERNAL_STORAGE As String
        Allows an application to read from external storage. Note: Starting in API level 33, this permission has no effect. If your app accesses other apps' media files, request one or more of these permissions instead: READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, READ_MEDIA_AUDIO.
        Starting in API level 29, applications don't need to request this permission to access files in their app-specific directory on external storage, or their own files in the MediaStore. Apps shouldn't request this permission unless they need to access other apps' files in the MediaStore.
        Constant Value: "android.permission.READ_EXTERNAL_STORAGE".
        Add line to manifest: <code>AddPermission("android.permission.READ_EXTERNAL_STORAGE")</code>
        Added in API level 16.
      • DANGEROUS_READ_MEDIA_AUDIO As String
        Allows an application to read audio files from external storage.
        Constant Value: "android.permission.READ_MEDIA_AUDIO".
        Add line to manifest: <code>AddPermission("android.permission.READ_MEDIA_AUDIO")</code>
        Added in API level 33.
      • DANGEROUS_READ_MEDIA_IMAGES As String
        Allows an application to read image files from external storage.
        Constant Value: "android.permission.READ_MEDIA_IMAGES".
        Add line to manifest: <code>AddPermission("android.permission.READ_MEDIA_IMAGES")</code>
        Added in API level 33.
      • DANGEROUS_READ_MEDIA_VIDEO As String
        Allows an application to read video files from external storage.
        Constant Value: "android.permission.READ_MEDIA_VIDEO".
        Add line to manifest: <code>AddPermission("android.permission.READ_MEDIA_VIDEO")</code>
        Added in API level 33.
      • DANGEROUS_READ_PHONE_NUMBERS As String
        Allows read access to the device's phone number(s). This is a subset of the capabilities granted by READ_PHONE_STATE but is exposed to instant applications.
        Constant Value: "android.permission.READ_PHONE_NUMBERS".
        Add line to manifest: <code>AddPermission("android.permission.READ_PHONE_NUMBERS")</code>
        Added in API level 26.
      • DANGEROUS_READ_PHONE_STATE As String
        Allows read only access to phone state, including the current cellular network information, the status of any ongoing calls, and a list of any PhoneAccounts registered on the device.
        Constant Value: "android.permission.READ_PHONE_STATE".
        Add line to manifest: <code>AddPermission("android.permission.READ_PHONE_STATE")</code>
        Added in API level 1.
      • DANGEROUS_READ_SMS As String
        Allows an application to read SMS messages.
        Constant Value: "android.permission.READ_SMS".
        Add line to manifest: <code>AddPermission("android.permission.READ_SMS")</code>
        Added in API level 1.
      • DANGEROUS_RECEIVE_MMS As String
        Allows an application to monitor incoming MMS messages.
        Constant Value: "android.permission.RECEIVE_MMS".
        Add line to manifest: <code>AddPermission("android.permission.RECEIVE_MMS")</code>
        Added in API level 1.
      • DANGEROUS_RECEIVE_SMS As String
        Allows an application to receive SMS messages.
        Constant Value: "android.permission.RECEIVE_SMS".
        Add line to manifest: <code>AddPermission("android.permission.RECEIVE_SMS")</code>
        Added in API level 1.
      • DANGEROUS_RECEIVE_WAP_PUSH As String
        Allows an application to receive WAP push messages.
        Constant Value: "android.permission.RECEIVE_WAP_PUSH".
        Add line to manifest: <code>AddPermission("android.permission.RECEIVE_WAP_PUSH")</code>
        Added in API level 1.
      • DANGEROUS_RECORD_AUDIO As String
        Allows an application to record audio.
        Constant Value: "android.permission.RECORD_AUDIO".
        Add line to manifest: <code>AddPermission("android.permission.RECORD_AUDIO")</code>
        Added in API level 1.
      • DANGEROUS_SEND_SMS As String
        Allows an application to send SMS messages.
        Constant Value: "android.permission.SEND_SMS".
        Add line to manifest: <code>AddPermission("android.permission.SEND_SMS")</code>
        Added in API level 1.
      • DANGEROUS_USE_SIP As String
        Allows an application to use SIP service.
        Constant Value: "android.permission.USE_SIP".
        Add line to manifest: <code>AddPermission("android.permission.USE_SIP")</code>
        Added in API level 9.
      • DANGEROUS_UWB_RANGING As String
        Required to be able to range to devices using ultra-wideband.
        Constant Value: "android.permission.UWB_RANGING".
        Add line to manifest: <code>AddPermission("android.permission.UWB_RANGING")</code>
        Added in API level 31.
      • DANGEROUS_WRITE_CALENDAR As String
        Allows an application to write the user's calendar data.
        Constant Value: "android.permission.WRITE_CALENDAR".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_CALENDAR")</code>
        Added in API level 1.
      • DANGEROUS_WRITE_CALL_LOG As String
        Allows an application to write (but not read) the user's call log data.
        Constant Value: "android.permission.WRITE_CALL_LOG".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_CALL_LOG")</code>
        Added in API level 16.
      • DANGEROUS_WRITE_CONTACTS As String
        Allows an application to write the user's contacts data.
        Constant Value: "android.permission.WRITE_CONTACTS".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_CONTACTS")</code>
        Added in API level 1.
      • DANGEROUS_WRITE_EXTERNAL_STORAGE As String
        Allows an application to write to external storage. Note: If your application targets API level 29 or higher, this permission has no effect.
        Constant Value: "android.permission.WRITE_EXTERNAL_STORAGE".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_EXTERNAL_STORAGE")</code>
        Added in API level 4.
      • SPECIAL_APP_NOTIFICATION As String
        Show notification settings for a single application (in most case's it's unrestricted by default).
        Constant Value: "android.settings.APP_NOTIFICATION_SETTINGS"
        Added in API level 26.
      • SPECIAL_APP_NOTIFICATION_BUBBLE As String
        Show notification bubble settings for a single application.
        Constant Value: "android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS"
        Added in API level 29.
      • SPECIAL_IGNORE_BACKGROUND_DATA_RESTRICTIONS As String
        Show screen for controlling background data restrictions for a particular application (in most case's it's unrestricted by default).
        Constant Value: "android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS"
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_NETWORK_STATE")</code>
        Added in API level 24.
      • SPECIAL_INSTALL_FROM_UNKNOWN_SOURCES As String
        Allows to install applications from unknown sources.
        Added in API level 1.
        Deprecated in API level 26. Use SPECIAL_REQUEST_INSTALL_PACKAGES instead.
        Use this permission only for devices up to SDK25. In higher SDK versions, this setting does not exist and during the check, the return result will always be False.
      • SPECIAL_MANAGE_EXTERNAL_STORAGE As String
        Allows an application a broad access to external storage in scoped storage. Intended to be used by few applications that need to manage files on behalf of the users.
        Constant Value: "android.permission.MANAGE_EXTERNAL_STORAGE".
        Add line to manifest: <code>AddPermission("android.permission.MANAGE_EXTERNAL_STORAGE")</code>
        Added in API level 30.
      • SPECIAL_MANAGE_MEDIA As String
        Allows an application to modify and delete media files on this device or any connected storage device without user confirmation.
        IMPORTANT: Applications must already be granted the READ_EXTERNAL_STORAGE or MANAGE_EXTERNAL_STORAGE permissions for this permission to take effect.
        Constant Value: "android.permission.MANAGE_MEDIA".
        Add line to manifest: <code>AddPermission("android.permission.MANAGE_MEDIA")</code>
        Added in API level 31.
      • SPECIAL_PACKAGE_USAGE_STATS As String
        Allows an application to collect component usage statistics.
        Constant Value: "android.permission.PACKAGE_USAGE_STATS".
        Add line to manifest: <code>AddPermission("android.permission.PACKAGE_USAGE_STATS")</code>
        Added in API level 23.
      • SPECIAL_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS As String
        Constant Value: "android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS".
        Add line to manifest: <code>AddPermission("android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS")</code>
        Added in API level 23.
      • SPECIAL_REQUEST_INSTALL_PACKAGES As String
        Allows an application to request installing packages. Applications targeting APIs greater than 25 must hold this permission in order to use Intent.ACTION_INSTALL_PACKAGE.
        Constant Value: "android.permission.REQUEST_INSTALL_PACKAGES".
        Add line to manifest: <code>AddPermission("android.permission.REQUEST_INSTALL_PACKAGES")</code>
        Added in API level 26.
        For lower SDK devices use SPECIAL_INSTALL_FROM_UNKNOWN_SOURCES.
      • SPECIAL_SCHEDULE_EXACT_ALARM As String
        Allows applications to use exact alarm APIs.
        This is a special access permission that can be revoked by the system or the user. It should only be used to enable user-facing features that require exact alarms.
        Constant Value: "android.permission.SCHEDULE_EXACT_ALARM".
        Add line to manifest: <code>AddPermission("android.permission.SCHEDULE_EXACT_ALARM")</code>
        Added in API level 31.
      • SPECIAL_SYSTEM_ALERT_WINDOW As String
        Allows an application to be shown on top of all other applications. Very few applications should use this permission; these windows are intended for system-level interaction with the user.
        Constant Value: "android.permission.SYSTEM_ALERT_WINDOW".
        Add line to manifest: <code>AddPermission("android.permission.SYSTEM_ALERT_WINDOW")</code>
        Added in API level 1.
      • SPECIAL_WRITE_SETTINGS As String
        Allows an application to read or write the system settings.
        Constant Value: "android.permission.WRITE_SETTINGS".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_SETTINGS")</code>
        Added in API level 1
  • PermissionsManager
    • Events:
      • ApplicationResumeAllowed
    • Functions:
      • CheckAndRequestPermission (Permission As String)
        Checks whether the application has been granted the specified permission. If not then the user will be shown a dialog asking for permission.
        The Activity_PermissionResult or B4XPage_PermissionResult will be raised with the result (in all cases).
        This method can only be called from an Activity.
      • CheckAndRequestPermission2 (Permission As String, DescriptionDialogText As String, DescriptionDialogTitle As String, DialogCloseButtonText As String)
        Checks whether the application has been granted the specified permission. If not, dialog with specified DescriptionText and Title will be shown in which you can explain to user for what the application requires this permission. After user closes dialog, a default dialog with asking for permission will be shown.
        The Activity_PermissionResult or B4XPage_PermissionResult will be raised with the result (in all cases).
        This method can only be called from an Activity.
      • CheckPermission (Permission As String) As Boolean
        Checks whether the application has been granted the specified permission.
        This method can be called from a Service.
      • GetAllSafeDirsExternal (subFolder As String) As List
        Returns an List with all the external folders available to your application.
        The first element will be the same as the value returned from GetSafeDirDefaultExternal.
        On Android 4.4+ no permission is required to access these folders.
        On older versions only one folder will be returned. You should add the permission as explained in GetSafeDirDefaultExternal documentation.
        SubFolder - A sub folder that will be created for your application. Pass an empty string if not needed.
      • GetSafeDirDefaultExternal (subFolder As String) As String
        Returns the path to the app's default folder on the secondary storage device.
        The path to File.DirInternal will be returned if there is no secondary storage available.
        It is a better alternative to File.DirDefaultExternal. On Android 4.4+ no permission is required to access this folder.
        SubFolder - A sub folder that will be created for your application. Pass an empty string if not needed.
      • IsDangerous (Permission As String) As Boolean
        Check if the permission is Dangerous permission.
      • IsDangerousOrSpecial (Permission As String) As Boolean
        Check if the permission is Special or Dangerous permission.
      • IsSpecial (Permission As String) As Boolean
        Check if the permission is Special permission.
    • Properties:
      • AllPermissionsInManifestFile As List [read only]
        Returns the List of all permissions specified in manifest file. You can use this list to ask for all permissions in manifest at the same time.
        Example: <code>
        For Each permission As String In PermissionManager1.AllPermissionsInManifestFile
        PermissionManager1.CheckAndRequestPermission(permission)
        Wait For Activity_PermissionResult (permission As String, Result As Boolean)
        Next</code>
      • ApplicationResumeAllowed As Boolean
        You can use this property to prevent the application to resume until the permissions requesting process will finish. Before start of permissions requesting process you need to set this value to False. When permissions process is finished, you must set this value to True. PermissionsManager_ApplicationResumeAllowed event will be triggered when you set value to True. Default value is True.
        Example: <code>
        PermissionManager1.ApplicationResumeAllowed=False 'Start preventing Application to resume.
        For Each permission As String In PermissionManager1.AllPermissionsInManifestFile
        PermissionManager1.CheckAndRequestPermission(permission)
        Wait For Activity_PermissionResult (permission As String, Result As Boolean)
        Next
        PermissionManager1.ApplicationResumeAllowed=True 'Stop preventing Application to resume.</code>
        On Activity_Resume or other part of code for which you want to prevent to resume until permissions requesting process is ended:
        Example:<code>
        If PermissionsManager1.ApplicationResumeAllowed=False Then
        Wait For PermissionsManager_ApplicationResumeAllowed
        End If
        'Rest of the code...</code>
      • DeviceSDK As Int [read only]
        Returns the integer value of device's SDK version.
        You don't need Phone library.

If this library makes your work easier and saves time in creating your application, please make a donation.
 

Attachments

  • PermissionsManager_1.3.zip
    34.3 KB · Views: 437
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Very interesting, thanks. I already had my code to request special permissions, but having them all collected in one library is very convenient
 

Ivica Golubovic

Active Member
Licensed User
Very interesting, thanks. I already had my code to request special permissions, but having them all collected in one library is very convenient
In the future of Android development, there will be more and more "special" permissions. I think it is necessary to include them in some library for easier access.
 

yiankos1

Well-Known Member
Licensed User
Longtime User
Which ones are you referring to exactly? Give me an example...
 

Marc DANIEL

Well-Known Member
Licensed User
Ivica, c'est vraiment génial. J'étais à la recherche de solutions pour mettre à jour une application bloquée après le passage à Android 13 sur mon Smartphone SONY XPERIA 1iii alors qu'elle fonctionne toujours parfaitement sur mon vieux SONY fonctionnant sous Android 9.
Toutes mes félicitations !!!
 

Ivica Golubovic

Active Member
Licensed User
Version 1.1
Download library from the first post.

Changes:
  • Added special permission SPECIAL_APP_NOTIFICATION in permissions constants.
  • Added special permission SPECIAL_APP_NOTIFICATION_BUBBLE in permissions constants.
  • Added special permission SPECIAL_IGNORE_BACKGROUND_DATA_RESTRICTIONS in permissions constants.
  • Reduced size of the final application by 0.5MB, also compared to the RuntimePermissions library.
 

Ivica Golubovic

Active Member
Licensed User
Awesome library. Many thanks for that. However, I have one small request (if I may):
when using CheckAndRequestPermission2, and if I click outside the messagebox (not on the DialogCloseButton) , application won't go further. Would it be possible to make it that even outside click will evoke application to go on?
Thanks for your time :)
It will be fixed in the next update. Thanks for letting me know.
 

stari

Active Member
Licensed User
Longtime User
PermissionsManager is a library that enables the management of runtime permissions. This library completely replaces the standard RuntimePermissions library with the addition of modern dangerous permissions and special permissions that require approval via the settings application.

This library contains constants for:
  1. Dangerous permissions,
  2. Special permissions.

For both types of permissions, the request principle is the same and is performed via one of the CheckAndRequestPermission methods. Example:
Dangerous:
Dim PM As PermissionsManager
PM.CheckAndRequestPermission(PM.Constants.DANGEROUS_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
'or
'Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result Then
    'Allowed
End If
Special:
Dim PM As PermissionsManager
PM.CheckAndRequestPermission(PM.Constants.SPECIAL_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
'or
'Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result Then
    'Allowed
End If
Of course, all permissions must be declared in the manifest, either automatically or manually.

As of version 1.2, the PermissionsManagerFileProvider class is included in the library. This FileProvider reduces the size of the final application by 0.5MB compared to the standard B4A FileProvider. This is made possible by wrapping the FileProvider class from the androidx.core:core package.

To use PermissionsManagerFileProvider add the following lines to the manifest:
Manifest::
AddApplicationText(
<provider
android:name="igolub.permissionmanager.b4a.PMFileProvider"
android:authorities="$PACKAGE$.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
)
CreateResource(xml, provider_paths,
<files-path name="name" path="shared" />
)

PermissionsManager
Author:
Ivica Golubovic
Version: 1.2
  • PermissionsManager
    • Events:
      • ApplicationResumeAllowed
    • Fields:
      • Constants As PermissionsManagerConstants
        Constants for all Dangerous and Special permissions.
        Dangerous - permissions which require user action to allow access to devices resources. Permissions dialog will be shown.
        Special - permissions which require user action to allow access to devices resources. Settings application Activity will be started.
    • Functions:
      • CheckAndRequestPermission (Permission As String)
        Checks whether the application has been granted the specified permission. If not then the user will be shown a dialog asking for permission.
        The Activity_PermissionResult or B4XPage_PermissionResult will be raised with the result (in all cases).
        This method can only be called from an Activity.
      • CheckAndRequestPermission2 (Permission As String, DescriptionDialogText As String, DescriptionDialogTitle As String, DialogCloseButtonText As String)
        Checks whether the application has been granted the specified permission. If not, dialog with specified DescriptionText and Title will be shown in which you can explain to user for what the application requires this permission. After user closes dialog, a default dialog with asking for permission will be shown.
        The Activity_PermissionResult or B4XPage_PermissionResult will be raised with the result (in all cases).
        This method can only be called from an Activity.
      • CheckPermission (Permission As String) As Boolean
        Checks whether the application has been granted the specified permission.
        This method can be called from a Service.
      • GetAllSafeDirsExternal (subFolder As String) As List
        Returns an List with all the external folders available to your application.
        The first element will be the same as the value returned from GetSafeDirDefaultExternal.
        On Android 4.4+ no permission is required to access these folders.
        On older versions only one folder will be returned. You should add the permission as explained in GetSafeDirDefaultExternal documentation.
        SubFolder - A sub folder that will be created for your application. Pass an empty string if not needed.
      • GetSafeDirDefaultExternal (subFolder As String) As String
        Returns the path to the app's default folder on the secondary storage device.
        The path to File.DirInternal will be returned if there is no secondary storage available.
        It is a better alternative to File.DirDefaultExternal. On Android 4.4+ no permission is required to access this folder.
        SubFolder - A sub folder that will be created for your application. Pass an empty string if not needed.
    • Properties:
      • AllPermissionsInManifestFile As List [read only]
        Returns the List of all permissions specified in manifest file. You can use this list to ask for all permissions in manifest at the same time.
        Example: <code>
        For Each permission As String In PermissionManager1.AllPermissionsInManifestFile
        PermissionManager1.CheckAndRequestPermission(permission)
        Wait For Activity_PermissionResult (permission As String, Result As Boolean)
        Next</code>
      • ApplicationResumeAllowed As Boolean
        You can use this property to prevent the application to resume until the permissions requesting process will finish. Before start of permissions requesting process you need to set this value to False. When permissions process is finished, you must set this value to True. PermissionsManager_ApplicationResumeAllowed event will be triggered when you set value to True. Default value is True.
        Example: <code>
        PermissionManager1.ApplicationResumeAllowed=False 'Start preventing Application to resume.
        For Each permission As String In PermissionManager1.AllPermissionsInManifestFile
        PermissionManager1.CheckAndRequestPermission(permission)
        Wait For Activity_PermissionResult (permission As String, Result As Boolean)
        Next
        PermissionManager1.ApplicationResumeAllowed=True 'Stop preventing Application to resume.</code>
        On Activity_Resume or other part of code for which you want to prevent to resume until permissions requesting process is ended:
        Example:<code>
        If PermissionsManager1.ApplicationResumeAllowed=False Then
        Wait For PermissionsManager_ApplicationResumeAllowed
        End If
        'Rest of the code...</code>
      • DeviceSDK As Int [read only]
        Returns the integer value of device's SDK version.
        You don't need Phone library.
      • FileProvider As PermissionsManagerFileProvider [read only]
        Copy next lines to manifest:<code>
        AddApplicationText(
        <provider
        android:name="igolub.permissionmanager.b4a.PMFileProvider"
        android:authorities="$PACKAGE$.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths"/>
        </provider>
        )
        CreateResource(xml, provider_paths,
        <files-path name="name" path="shared" />
        )
        </code>
  • PermissionsManagerConstants
    • Fields:
      • DANGEROUS_ACCEPT_HANDOVER As String
        Allows a calling application to continue a call which was started in another application. An example is a video calling application that wants to continue a voice call on the user's mobile network.
        Constant Value: "android.permission.ACCEPT_HANDOVER".
        Add line to manifest: <code>AddPermission("android.permission.ACCEPT_HANDOVER")</code>
        Added in API level 28.
      • DANGEROUS_ACCESS_BACKGROUND_LOCATION As String
        Allows an application To access location in the background. If you're requesting this permission, you must also request either ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION. Requesting this permission by itself doesn't give you location access.
        Constant Value: "android.permission.ACCESS_BACKGROUND_LOCATION".
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_BACKGROUND_LOCATION")</code>
        Added in API level 29..
      • DANGEROUS_ACCESS_COARSE_LOCATION As String
        Allows an application To access approximate location. Alternatively, you might want ACCESS_FINE_LOCATION.
        Constant Value: "android.permission.ACCESS_COARSE_LOCATION".
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_COARSE_LOCATION")</code>
        Added in API level 1.
      • DANGEROUS_ACCESS_FINE_LOCATION As String
        Allows an application to access precise location. Alternatively, you might want ACCESS_COARSE_LOCATION.
        Constant Value: "android.permission.ACCESS_FINE_LOCATION".
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_FINE_LOCATION")</code>
        Added in API level 1.
      • DANGEROUS_ACCESS_MEDIA_LOCATION As String
        Allows an application to access any geographic locations persisted in the user's shared collection.
        Constant Value: "android.permission.ACCESS_MEDIA_LOCATION".
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_MEDIA_LOCATION")</code>
        Added in API level 29.
      • DANGEROUS_ACTIVITY_RECOGNITION As String
        Allows an application to recognise physical activity.
        Constant Value: "android.permission.ACTIVITY_RECOGNITION".
        Add line to manifest: <code>AddPermission("android.permission.ACTIVITY_RECOGNITION")</code>
        Added in API level 29.
      • DANGEROUS_ADD_VOICEMAIL As String
        Allows an application to add voice mails into the system.
        Constant Value: "com.android.voicemail.permission.ADD_VOICEMAIL".
        Add line to manifest: <code>AddPermission("com.android.voicemail.permission.ADD_VOICEMAIL")</code>
        Added in API level 14.
      • DANGEROUS_ANSWER_PHONE_CALLS As String
        Allows the application to answer an incoming phone call.
        Constant Value: "android.permission.ANSWER_PHONE_CALLS".
        Add line to manifest: <code>AddPermission("android.permission.ANSWER_PHONE_CALLS")</code>
        Added in API level 26.
      • DANGEROUS_BLUETOOTH_ADVERTISE As String
        Required to be able to advertise to nearby Bluetooth devices.
        Constant Value: "android.permission.BLUETOOTH_ADVERTISE".
        Add line to manifest: <code>AddPermission("android.permission.BLUETOOTH_ADVERTISE")</code>
        Added in API level 31.
      • DANGEROUS_BLUETOOTH_CONNECT As String
        Required to be able to connect to paired Bluetooth devices.
        Constant Value: "android.permission.BLUETOOTH_CONNECT".
        Add line to manifest: <code>AddPermission("android.permission.BLUETOOTH_CONNECT")</code>
        Added in API level 31.
      • DANGEROUS_BLUETOOTH_SCAN As String
        Required to be able to discover and pair nearby Bluetooth devices.
        Constant Value: "android.permission.BLUETOOTH_SCAN".
        Add line to manifest: <code>AddPermission("android.permission.BLUETOOTH_SCAN")</code>
        Added in API level 31.
      • DANGEROUS_BODY_SENSORS As String
        Allows an application to access data from sensors that the user uses to measure what is happening inside their body, such as heart rate.
        Constant Value: "android.permission.BODY_SENSORS".
        Add line to manifest: <code>AddPermission("android.permission.BODY_SENSORS")</code>
        Added in API level 20.
      • DANGEROUS_BODY_SENSORS_BACKGROUND As String
        Allows an application to access data from sensors that the user uses to measure what is happening inside their body, such as heart rate. If you're requesting this permission, you must also request BODY_SENSORS. Requesting this permission by itself doesn't give you Body sensors access.
        Constant Value: "android.permission.BODY_SENSORS_BACKGROUND".
        Add line to manifest: <code>AddPermission("android.permission.BODY_SENSORS_BACKGROUND")</code>
        Added in API level 33.
      • DANGEROUS_CALL_PHONE As String
        Allows an application to initiate a phone call without going through the Dialler user interface for the user to confirm the call.
        Constant Value: "android.permission.CALL_PHONE".
        Add line to manifest: <code>AddPermission("android.permission.CALL_PHONE")</code>
        Added in API level 1.
      • DANGEROUS_CAMERA As String
        Required to be able to access the camera device. This will automatically enforce the uses-feature manifest element for all camera features. If you do not require all camera features or can properly operate if a camera is not available, then you must modify your manifest as appropriate in order to install on devices that don't support all camera features.
        Constant Value: "android.permission.CAMERA".
        Add line to manifest: <code>AddPermission("android.permission.CAMERA")</code>
        Added in API level 1.
      • DANGEROUS_GET_ACCOUNTS As String
        Allows access to the list of accounts in the Accounts Service.
        Constant Value: "android.permission.GET_ACCOUNTS".
        Add line to manifest: <code>AddPermission("android.permission.GET_ACCOUNTS")</code>
        Added in API level 1.
      • DANGEROUS_NEARBY_WIFI_DEVICES As String
        Required to be able to advertise and connect to nearby devices via Wi-Fi.
        Constant Value: "android.permission.NEARBY_WIFI_DEVICES".
        Add line to manifest: <code>AddPermission("android.permission.NEARBY_WIFI_DEVICES")</code>
        Added in API level 33.
      • DANGEROUS_POST_NOTIFICATIONS As String
        Allows an application to post notifications.
        Constant Value: "android.permission.POST_NOTIFICATIONS".
        Add line to manifest: <code>AddPermission("android.permission.POST_NOTIFICATIONS")</code>
        Added in API level 33.
      • DANGEROUS_PROCESS_OUTGOING_CALLS As String
        Allows an application to see the number being dialled during an outgoing call with the option to redirect the call to a different number or abort the call altogether.
        Constant Value: "android.permission.PROCESS_OUTGOING_CALLS".
        Add line to manifest: <code>AddPermission("android.permission.PROCESS_OUTGOING_CALLS")</code>
        Added in API level 1.
        Deprecated in API level 29.
      • DANGEROUS_READ_CALENDAR As String
        Allows an application to read the user's calendar data.
        Constant Value: "android.permission.READ_CALENDAR".
        Add line to manifest: <code>AddPermission("android.permission.READ_CALENDAR")</code>
        Added in API level 1.
      • DANGEROUS_READ_CALL_LOG As String
        Allows an application to read the user's call log.
        Constant Value: "android.permission.READ_CALL_LOG".
        Add line to manifest: <code>AddPermission("android.permission.READ_CALL_LOG")</code>
        Added in API level 16.
      • DANGEROUS_READ_CONTACTS As String
        Allows an application to read the user's contacts data.
        Constant Value: "android.permission.READ_CONTACTS".
        Add line to manifest: <code>AddPermission("android.permission.READ_CONTACTS")</code>
        Added in API level 1.
      • DANGEROUS_READ_EXTERNAL_STORAGE As String
        Allows an application to read from external storage. Note: Starting in API level 33, this permission has no effect. If your app accesses other apps' media files, request one or more of these permissions instead: READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, READ_MEDIA_AUDIO.
        Starting in API level 29, applications don't need to request this permission to access files in their app-specific directory on external storage, or their own files in the MediaStore. Apps shouldn't request this permission unless they need to access other apps' files in the MediaStore.
        Constant Value: "android.permission.READ_EXTERNAL_STORAGE".
        Add line to manifest: <code>AddPermission("android.permission.READ_EXTERNAL_STORAGE")</code>
        Added in API level 16.
      • DANGEROUS_READ_MEDIA_AUDIO As String
        Allows an application to read audio files from external storage.
        Constant Value: "android.permission.READ_MEDIA_AUDIO".
        Add line to manifest: <code>AddPermission("android.permission.READ_MEDIA_AUDIO")</code>
        Added in API level 33.
      • DANGEROUS_READ_MEDIA_IMAGES As String
        Allows an application to read image files from external storage.
        Constant Value: "android.permission.READ_MEDIA_IMAGES".
        Add line to manifest: <code>AddPermission("android.permission.READ_MEDIA_IMAGES")</code>
        Added in API level 33.
      • DANGEROUS_READ_MEDIA_VIDEO As String
        Allows an application to read video files from external storage.
        Constant Value: "android.permission.READ_MEDIA_VIDEO".
        Add line to manifest: <code>AddPermission("android.permission.READ_MEDIA_VIDEO")</code>
        Added in API level 33.
      • DANGEROUS_READ_PHONE_NUMBERS As String
        Allows read access to the device's phone number(s). This is a subset of the capabilities granted by READ_PHONE_STATE but is exposed to instant applications.
        Constant Value: "android.permission.READ_PHONE_NUMBERS".
        Add line to manifest: <code>AddPermission("android.permission.READ_PHONE_NUMBERS")</code>
        Added in API level 26.
      • DANGEROUS_READ_PHONE_STATE As String
        Allows read only access to phone state, including the current cellular network information, the status of any ongoing calls, and a list of any PhoneAccounts registered on the device.
        Constant Value: "android.permission.READ_PHONE_STATE".
        Add line to manifest: <code>AddPermission("android.permission.READ_PHONE_STATE")</code>
        Added in API level 1.
      • DANGEROUS_READ_SMS As String
        Allows an application to read SMS messages.
        Constant Value: "android.permission.READ_SMS".
        Add line to manifest: <code>AddPermission("android.permission.READ_SMS")</code>
        Added in API level 1.
      • DANGEROUS_RECEIVE_MMS As String
        Allows an application to monitor incoming MMS messages.
        Constant Value: "android.permission.RECEIVE_MMS".
        Add line to manifest: <code>AddPermission("android.permission.RECEIVE_MMS")</code>
        Added in API level 1.
      • DANGEROUS_RECEIVE_SMS As String
        Allows an application to receive SMS messages.
        Constant Value: "android.permission.RECEIVE_SMS".
        Add line to manifest: <code>AddPermission("android.permission.RECEIVE_SMS")</code>
        Added in API level 1.
      • DANGEROUS_RECEIVE_WAP_PUSH As String
        Allows an application to receive WAP push messages.
        Constant Value: "android.permission.RECEIVE_WAP_PUSH".
        Add line to manifest: <code>AddPermission("android.permission.RECEIVE_WAP_PUSH")</code>
        Added in API level 1.
      • DANGEROUS_RECORD_AUDIO As String
        Allows an application to record audio.
        Constant Value: "android.permission.RECORD_AUDIO".
        Add line to manifest: <code>AddPermission("android.permission.RECORD_AUDIO")</code>
        Added in API level 1.
      • DANGEROUS_SEND_SMS As String
        Allows an application to send SMS messages.
        Constant Value: "android.permission.SEND_SMS".
        Add line to manifest: <code>AddPermission("android.permission.SEND_SMS")</code>
        Added in API level 1.
      • DANGEROUS_USE_SIP As String
        Allows an application to use SIP service.
        Constant Value: "android.permission.USE_SIP".
        Add line to manifest: <code>AddPermission("android.permission.USE_SIP")</code>
        Added in API level 9.
      • DANGEROUS_UWB_RANGING As String
        Required to be able to range to devices using ultra-wideband.
        Constant Value: "android.permission.UWB_RANGING".
        Add line to manifest: <code>AddPermission("android.permission.UWB_RANGING")</code>
        Added in API level 31.
      • DANGEROUS_WRITE_CALENDAR As String
        Allows an application to write the user's calendar data.
        Constant Value: "android.permission.WRITE_CALENDAR".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_CALENDAR")</code>
        Added in API level 1.
      • DANGEROUS_WRITE_CALL_LOG As String
        Allows an application to write (but not read) the user's call log data.
        Constant Value: "android.permission.WRITE_CALL_LOG".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_CALL_LOG")</code>
        Added in API level 16.
      • DANGEROUS_WRITE_CONTACTS As String
        Allows an application to write the user's contacts data.
        Constant Value: "android.permission.WRITE_CONTACTS".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_CONTACTS")</code>
        Added in API level 1.
      • DANGEROUS_WRITE_EXTERNAL_STORAGE As String
        Allows an application to write to external storage. Note: If your application targets API level 29 or higher, this permission has no effect.
        Constant Value: "android.permission.WRITE_EXTERNAL_STORAGE".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_EXTERNAL_STORAGE")</code>
        Added in API level 4.
      • SPECIAL_APP_NOTIFICATION As String
        Show notification settings for a single application (in most case's it's unrestricted by default).
        Constant Value: "android.settings.APP_NOTIFICATION_SETTINGS"
        Added in API level 26.
      • SPECIAL_APP_NOTIFICATION_BUBBLE As String
        Show notification bubble settings for a single application.
        Constant Value: "android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS"
        Added in API level 29.
      • SPECIAL_IGNORE_BACKGROUND_DATA_RESTRICTIONS As String
        Show screen for controlling background data restrictions for a particular application (in most case's it's unrestricted by default).
        Constant Value: "android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS"
        Add line to manifest: <code>AddPermission("android.permission.ACCESS_NETWORK_STATE")</code>
        Added in API level 24.
      • SPECIAL_MANAGE_EXTERNAL_STORAGE As String
        Allows an application a broad access to external storage in scoped storage. Intended to be used by few applications that need to manage files on behalf of the users.
        Constant Value: "android.permission.MANAGE_EXTERNAL_STORAGE".
        Add line to manifest: <code>AddPermission("android.permission.MANAGE_EXTERNAL_STORAGE")</code>
        Added in API level 30.
      • SPECIAL_MANAGE_MEDIA As String
        Allows an application to modify and delete media files on this device or any connected storage device without user confirmation.
        IMPORTANT: Applications must already be granted the READ_EXTERNAL_STORAGE or MANAGE_EXTERNAL_STORAGE permissions for this permission to take effect.
        Constant Value: "android.permission.MANAGE_MEDIA".
        Add line to manifest: <code>AddPermission("android.permission.MANAGE_MEDIA")</code>
        Added in API level 31.
      • SPECIAL_PACKAGE_USAGE_STATS As String
        Allows an application to collect component usage statistics.
        Constant Value: "android.permission.PACKAGE_USAGE_STATS".
        Add line to manifest: <code>AddPermission("android.permission.PACKAGE_USAGE_STATS")</code>
        Added in API level 23.
      • SPECIAL_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS As String
        Constant Value: "android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS".
        Add line to manifest: <code>AddPermission("android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS")</code>
        Added in API level 23.
      • SPECIAL_REQUEST_INSTALL_PACKAGES As String
        Allows an application to request installing packages. Applications targeting APIs greater than 25 must hold this permission in order to use Intent.ACTION_INSTALL_PACKAGE.
        Constant Value: "android.permission.REQUEST_INSTALL_PACKAGES".
        Add line to manifest: <code>AddPermission("android.permission.REQUEST_INSTALL_PACKAGES")</code>
        Added in API level 23
      • SPECIAL_SCHEDULE_EXACT_ALARM As String
        Allows applications to use exact alarm APIs.
        This is a special access permission that can be revoked by the system or the user. It should only be used to enable user-facing features that require exact alarms.
        Constant Value: "android.permission.SCHEDULE_EXACT_ALARM".
        Add line to manifest: <code>AddPermission("android.permission.SCHEDULE_EXACT_ALARM")</code>
        Added in API level 31.
      • SPECIAL_SYSTEM_ALERT_WINDOW As String
        Allows an application to be shown on top of all other applications. Very few applications should use this permission; these windows are intended for system-level interaction with the user.
        Constant Value: "android.permission.SYSTEM_ALERT_WINDOW".
        Add line to manifest: <code>AddPermission("android.permission.SYSTEM_ALERT_WINDOW")</code>
        Added in API level 1.
      • SPECIAL_WRITE_SETTINGS As String
        Allows an application to read or write the system settings.
        Constant Value: "android.permission.WRITE_SETTINGS".
        Add line to manifest: <code>AddPermission("android.permission.WRITE_SETTINGS")</code>
        Added in API level 1
  • PermissionsManagerFileProvider
    Copy next lines to manifest:<code>
    AddApplicationText(
    <provider
    android:name="igolub.permissionmanager.b4a.PMFileProvider"
    android:authorities="$PACKAGE$.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
    android:name="android.support.FILE_PROVIDER_PATHS"
    android:resource="@xml/provider_paths"/>
    </provider>
    )
    CreateResource(xml, provider_paths,
    <files-path name="name" path="shared" />
    )
    </code>
    • Fields:
      • SharedFolder As String
      • UseFileProvider As Boolean
    • Functions:
      • GetFileUri (FileName As String) As Object
      • SetFileUriAsIntentData (mIntent As Intent, FileName As String)

If this library makes your work easier and saves time in creating your application, please make a donation.
Very usefull.
Zelo uporabno, Ivica!
Vrlo korisno, Ivica !
 

Ivica Golubovic

Active Member
Licensed User
Version 1.3
Download library from the first post.

Changes:
  • Added Method IsDangerous to PermissionsManager class.
  • Added Method IsDangerousOrSpecial to PermissionsManager class.
  • Added Method IsSpecial to PermissionsManager class.
  • Removed PermissionsManagerConstants static class module. Use PermissionsManager static class module instead (B4X module).
  • Removed PermissionsManagerFileProvider class. Use FileProvider static class module instead (B4X module).
  • Added SPECIAL_INSTALL_FROM_UNKNOWN_SOURCES special permission (Use this permission only for devices up to SDK25).
  • Other changes...
  • Bugs fixes.
 

PJLPJLPJL

Member
Licensed User
I'm probably being very stupid, but I can't find the Static Class Modules refered to in v1.3 (Post #18) for PermissionsManager and FileProvider.
Could you please explain where they are?
Huge thanks.
 
Top