- How permissions work
- Install-time permissions
- Runtime permissions
- Special case: background location
- Advanced permission management in WLanguage
Android permission management
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.
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.
There are different types of permission:
- Install-time permissions.
- Runtime 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, 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 request two permissions:
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,
- 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:
- The Permission type:
|Permission||A Permission variable represents a permission requested by the application (and therefore declared in the manifest).|
Click [Add] to post a comment