PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Prompts the user to grant an application permission. This function makes it possible to show an information message to the user before the permission request.
Example
// Demande la permission pour autoriser la localisation précise de l'appareil
// avant d'appeler la fonction GPSRécupèrePosition
Perm is Permission = PermissionList("android.permission.ACCESS_FINE_LOCATION")
// Si la permission n'a pas déjà été accordée
IF NOT Perm.Granted THEN
// Message informatif
// Affiche un message à l'utilisateur pour lui indiquer
// pourquoi l'application a besoin de cette permission
Info("Cette permission est nécessaire pour xxxx")
// Demande la permission
PermissionRequest(Perm, ProcDemandePermission)
INTERNAL PROCÉDURE ProcDemandePermission(Perm is Permission)
IF Perm.Granted THEN
MaPosition is géoPosition GPSGetPosition()
...
END
END
END
Syntax

Requesting one permission Hide the details

PermissionRequest(<Permission> , <WLanguage procedure>)
<Permission>: Character string or Permission variable
Name of the permission to request. This parameter can correspond to:
  • a character string with the following format: android.permission.<NAME>. The list of permissions of the Android SDK can be found at: https://developer.android.com/reference/android/Manifest.permission.
  • to an variable of type Permission.
  • one of the following constants:
    permCameraPermission to access the device camera(s).
    permWriteContactPermission to modify contacts.
    permWriteExternalStoragePermission to write on the external storage.
    permRecordAudioPermission to record audio streams.
    permSendSMSPermission to send SMSes.
    permManageExternalStoragePermission to manage external storage. If this permission is requested, a system window will prompt the user to allow the application to access files on the external storage without restrictions.
    permReadContactPermission to read contacts.
    permReadPhoneStatePermission to access phone information.
    permLocationPermission to access the device's location.
    permBackgroundLocationPermission to access the device's location when the application is running in the background.
    Caution: This permission must be requested alone and after the acceptance of the permissions corresponding to the permLocation or permFineLocationconstants.
    permFineLocationPermission to access the device's precise location.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called when the permission request is approved. This procedure has the following format:
PROCEDURE <Nom de la procédure>(<Résultat>)
where <Result> is a Permission variable. The result of the permission request is assigned to the Granted property.

Requesting multiple permissions simultaneously Hide the details

PermissionRequest(<Permissions> , <WLanguage procedure>)
<Permissions>: Array
Requested permissions. This parameter can correspond to:
  • an array of strings in the following format: android.permission.<NAME>
  • an array of Permission variables.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called when the permission request is approved. This procedure has the following format:
PROCEDURE <Nom de la procédure>(<Résultat>)
where <Result> is an array of Permission variables. For each permission, the result of the permission request is assigned to the Granted property.
Remarks
  • The permBackgroundLocation or "android.permission.ACCESS_BACKGROUND_LOCATION" permission must be requested alone and after the acceptance of the permissions corresponding to the permLocation or permFineLocationconstants.
  • The permission must have been declared in the application manifest. Otherwise, a fatal error will occur.
  • It is not necessary to call PermissionRequest for "normal" permissions (as opposed to "dangerous" permissions) because they are automatically granted when the application is installed, if they have been declared in the application manifest.
  • For "dangerous" permissions (access to the location of the device, camera, microphone, etc.), the Android framework automatically requests the permission when a relevant feature is used. However, PermissionRequest can be used when, for example, you want to display an information message to the user before requesting a permission.
  • If the permission has already been granted, no window will be displayed.
  • CAUTION: Since PermissionRequest can display a window for the user to approve the permission request, this function must be called from the main application thread.
  • To get the list of permissions declared by the application, use PermissionList.
Business / UI classification: Neutral code
Component: wd270android.aar
Minimum version required
  • Version 26
Comments
Click [Add] to post a comment