askForPermission (Android)
Ask the user to enable a dangerous feature on the Android device.
Syntax
ui.Interface.frontCall("android","askForPermission",
[permission], [result])
- permission - Identifies the Androidâ„¢ permission to enable.
- result - Holds the execution status of the front call:
"ok"
: the user accepted the permission."rejected"
: the user refused the permission.
Usage
The "askForPermission
" front call opens a message box, to let the
end user confirm the access to a "Dangerous Permission" on Android, to enable a risky feature of the mobile device.
askForPermission
front call has been introduced for Android
6: Since this version of Android, permissions to access dangerous mobile functions are no longer
asked during app installation: The app code must explicitly ask the user for dangerous permissions
when needed, with an askForPermission
front call.The permissions parameter defines the Android permission to be asked. It must be a string
representing one of the permission constants, as defined in Android's Manifest permissions, prefixed by the
"android.permission."
string. For example, the
"android.permission.WRITE_EXTERNAL_STORAGE"
string can be used to identify the
permission to access the SDCARD storage unit.
The front call will raise a runtime exception if the permission identifier is not valid.
Example
The following code example asks the user to access the SDCARD, and handles the user choice:
DEFINE result STRING
CALL ui.Interface.frontCall(
"android", "askForPermission",
["android.permission.WRITE_EXTERNAL_STORAGE"],
[result] )
CASE result
WHEN "ok"
CALL os.Path.mkDir("/sdcard/myfiles")
WHEN "rejected"
ERROR "SDCARD access was denied by user"
END CASE