Delphi Android permissions
One of the issues to consider, if we want our application to work, is the Android permissions (Android permissions).
If the device has Android 6 Marshmallow (API level 23), or the TargetSdkVersion App attribute is 23 or higher, the user must accept dangerous permissions.
Therefore, not only must we place the permissions in the application manifest, but we must also perform the functions that request the user’s said permissions so that they can accept or reject them.
What are the dangerous permissions
There are two types of permits, ordinary or ordinary permits and dangerous permits.
Regarding ordinary permissions, such as using the Internet, you only need to declare them in the list, while for dangerous permissions, we need user authorization.
In order to grant permissions in Delphi, we must enter the menu Project-> Options.
In the project options window, we will go to the Application->Uses Permissions section. In the target part, we must choose 32 or 64-bit Android platform according to the version to be compiled.
In the first case, a list of common permissions will appear, just select them and we can use it in the application and under “Dangerous permissions”.
Request Android permissions from Delphi
In this case, we will perform an example of requesting localized permissions. First, we will go to the menu Project-> Options, and then open the Application-> Uses Permissions section in the project options window.
n the “ordinary” permission, we select “Internet”, and in the “dangerous” permission, we select the permissions of “access rough location” and “access fine location”.
We should only request authorization from the user for the last two permissions, because this is dangerous.
The unit of handling permissions in Delphi is System.Permissions, so we must add it to Uses.
Second, declare a global variable for each dangerous permission we want to request. code show as below:
//The complete code of the unit requesting geographic location permission from the user is as follows: