PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
New WINDEV Mobile 26 feature!
  • Overview
  • Reminder: the target API level ("TargetSdkVersion")
  • Applications that request background location permission
  • Applications that require access to files
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
After each new version of Android is deployed, Google requires a higher target API level ("TargetSdkVersion") to publish applications on Google Play.
These are the changes that apply to applications:
  • Geolocation: Unable to combine ACCESS_FINE_LOCATION and ACCESS_BACKGROUND_LOCATION permission requests into one operation. This implies a change in the code of applications that use background location.
  • Access to files: applications in Android 11 can no longer access files created by another application by using their path. This implies a verification of the file handling processes and changes in the code, if necessary.

Reminder: the target API level ("TargetSdkVersion")

When an Android application is compiled, the generated APK includes a target API level ("TargetSdkVersion") of the Android SDK. With this level of target API, Android determines the features that can be included in the application, and the security rules that must be applied to it.
The target API level ("TargetSdkVersion") assigned to an application can be seen in the APK generation wizard, in the "Configuration" step:
  1. Click "Advanced configuration",
  2. In the "Advanced configuration" window, select "Edit manifest",
  3. Expand the "uses-sdk" node,
  4. "android:targetSdkVersion" shows the target API level.
For more details, see Google's website.
Applications that request background location permission
From WINDEV Mobile 26 Update 3, only the location permissions (ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION) will be integrated when generating the application, if necessary.
For applications that require background location access, you need to:
  1. Manually add the "ACCESS_BACKGROUND_LOCATION" permission in the Android application generation wizard.
  2. Explicitly request background location permission using PermissionRequest. For example:
    PermissionRequest(permBackgroundLocation, Callback)
    INTERNAL PROCEDURE Callback(p is Permission)
    IF p.Granted THEN
    // Functions that require background location access can be used
    END
    END
Remarks:
Applications that require access to files
Up to Android 10, applications can read and write files:
  • in the application directories on the internal storage (fCurrentDir, fExeDir, fDataDir)
  • almost anywhere in the external storage :
    • custom tree structure from the root of the external storage returned by SysDirStorageCard
    • in the application directories on the external storage: SysDirExternalStorage with sseAppXXX constants.
    • in public directories: Documents, Download, Images, etc. on external storage: SysDirExternalStorage with ssePublicXXX constants.Android applications can access files created by other applications on the external storage without restrictions.
When the application is used on a device that runs Android 11, new restrictions appear:
  • applications can no longer read or write files to the external storage outside of:
  • in public directories, applications can only access (read or write) files they have created.
    Remark: if the application is uninstalled and then reinstalled, it will no longer have access to files created by the version previously installed in the public directories of the external storage.
This means applications can no longer access files created by another application by using their path. The end user must select the files that the application can access. It is possible display a file picker using URISelect function and then handle the file by the URI returned by the function.
Likewise, SysDirStorageCard and the ssePublic constant of the SysDirExternalStorage function (external storage root directory) should not be used in new development projects.
However, there is a special permission to override these restrictions: MANAGE_EXTERNAL_STORAGE. To activate it, you must:
  • Manually add the MANAGE_EXTERNAL_STORAGE permission in the Android application generation wizard.
  • Explicitly request external storage access using PermissionRequest. For example:
    PermissionRequest(permManageExternalStorage, Callback)
    INTERNAL PROCEDURE Callback(p is Permission)
    IF p.Granted THEN
         // Functions that require external storage access can be used
    END
    END
This permission request does not open the standard permission popup, but will open a system window to allow the application to access all files on the external storage without restrictions.
Caution: if the application is to be published on Google Play, the use of this permission must be justified. Only file manager, antivirus or backup manager applications are allowed. In other cases, if this permission is used, the publication is very likely to be refused.
Alternative solution (for existing applications only) : Add the preserveLegacyExternalStorage attribute to the application manifest. The process for adding the preserveLegacyExternalStorage attribute to an application is detailed in FAQ 21 548: How to allow an existing application to access files on the external storage? (preserveLegacyExternalStorage attribute). This allows keeping the same access rules as before the API level change, but it will be effective only for existing applications. For new applications or applications that are uninstalled and then reinstalled, this option will be ignored.
Minimum version required
  • Version 26
Comments
Click [Add] to post a comment