PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • 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/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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.
  • Limitations on access to Mac addresses: The NetMACAddress function is no longer available. It always returns an empty string.

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:
  • Follow Google's guidelines for applications that require background location access. For more details, see https://support.google.com/googleplay/android-developer/answer/9799150. If these conditions are not met (especially user information requirements), applications may not be accepted for publication on Google Play.
  • The background location permission should only be requested if the location permission has been granted. Otherwise, PermissionRequest will fail.
  • If the option chosen by the user for the background location access request is more restrictive than the option chosen for the location access request, the application will be automatically restarted.
  • On devices running Android 10 or earlier, if location permission has been granted to the application, the background location permission will be granted without displaying a window.
  • The relevant WLanguage functions are as follows:
    BeaconDetectBackgroundNotifies the application when the device enters or leaves the transmission range of a set of Beacons.
    BeaconDetectPreciseUsed to find the Beacons near the device.
    BTLEListDeviceReturns the list of accessible Bluetooth Low Energy devices.
    BTListDeviceReturns the list of accessible Bluetooth devices.
    MapFollowMovementDisplays the current location of the device in a Map control and updates the location as it moves.
    geoTrackingEnableEnables the management of location tracking in a WINDEV Mobile application.
    GPSStopDetectionStops the location detection triggered by GPSDetectPosition.
    GPSLastPositionRetrieves the information about the last known device position.
    GPSDetectPositionAsks to be notified when the device gets close to a given location.
    GPSStatusRetrieves the activation status of the geolocation provider or asks to be notified when the status changes.
    GPSInfoReturns the information about the location provider used by the application for geolocation functions.
    GPSInitParameterInitializes the parameters of geolocation WLanguage functions and finds a location provider.
    GPSGetPositionRetrieves information about the current device position.
    GPSFollowMovementRequests to be notified periodically of the device's current location.
    MobileNetworkConnectionInfoReturns information regarding the current connection to data on the mobile network.
    WiFiDetectAccessPointStarts detecting the Wi-Fi access points currently accessible from the device.
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, an application can only access (in read or write mode) the files that it has 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