ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Mobile specific functions / Permission functions
  • Overview
  • How permissions work
  • Install-time permissions
  • Runtime permissions
  • Special case: background location
  • Advanced permission management in WLanguage
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
Overview
Android applications require permissions to provide certain features that may require access to sensitive data or sensitive device functionalities: take a picture, access location, list contacts, etc.
WINDEV Mobile automatically detects the necessary permissions according to the features used by the application (WLanguage functions, controls, etc.).
You can also add or remove them manually from the generation wizard. For runtime permissions, the Android framework automatically manages the user permission request when a relevant feature is used.
Everything is automatic.
However, in some situations, the developer needs to manage the application permissions more finely. A simple example: the developer needs to know if a permission has already been granted. If it is not the case, the developer needs to display a window explaining to the user why they have to grant a given permission in order to use an application feature.
WINDEV Mobile offers WLanguage functions and a variable type to manage permissions from the code.
How permissions work
All permissions required by an application must be declared in the application manifest. All these permissions can be viewed once the application has been installed on the device by going to the app info in the device settings.
The list of existing permissions can be found at: https://developer.android.com/reference/android/Manifest.permission.
There are different types of permission:
  • Install-time permissions.
  • Runtime permissions.

Install-time permissions

These permissions allow the application to access data or use features that minimally affect the system or other applications. When one of these permissions is declared in the application manifest, the system automatically grants the application this permission when the user installs the app, without any intervention.

Runtime permissions

Runtime permissions, also known as dangerous permissions, allow the application to access data or use restricted functionalities: private user data, location, microphone or camera, etc. Therefore, a user action is needed to grant the app this permission.
If the permission has not yet been granted, and the app tries to access certain functionalities or sensitive data, a prompt appears asking the user to grant permission to the application.
  • If the user grants this permission, the functionality or data becomes accessible and permission will no longer be requested unless the user revokes this permission in the application settings.
  • If the user denies this permission, the feature or data will not be accessible (usually this causes the corresponding WLanguage function to fail) and the permission will be requested again next time.
  • Starting with Android 11, the user can also grant a permission temporarily ("Only this time"). In this case, the permission is valid as long as the current window remains visible. If the application is sent to the background, the permission remains valid for a short period only.
    This type of permission is only available for location, camera and microphone permissions.

Special case: background location

To allow an application to access the location of the device in the background, you must do the following:
  1. Request the location permission (ACCESS_[FINE/COARSE]_LOCATION permission via PermissionRequest with the permLocation or permFineLocation constant).
  2. If the previous permission is granted, request background location access (ACCESS_BACKGROUND_LOCATION permission via PermissionRequest with the permBackgroundLocationconstant).
In this case, a special permission request window is displayed. This window includes options to allow access to the position of the device:
  • While using the app,
  • Only this time,
  • Deny,
  • Change the application settings.
The user can allow the application to access location when it is active ("While using the app"), temporarily, deny access, or go to the application settings to allow location access in the background.
Advanced permission management in WLanguage
To finely manage permissions, WLanguage includes:
  • Several functions:
    PermissionListReturns one or all the permissions declared by the application.
    PermissionRequestPrompts the user to grant an application permission.
  • The Permission type:
    PermissionThe Permission type represents a permission requested by the application (and therefore declared in the manifest).
Minimum version required
  • Version 26
Comments
Click [Add] to post a comment

Last update: 07/03/2023

Send a report | Local help