ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing for Android
  • Overview
  • Reminder: the target API level ("TargetSdkVersion")
  • Behavior of applications in the background
  • Overview
  • Changes from WINDEV Mobile 25 Update 3
  • List of related functions
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
Warning
From version 26 (93), WINDEV Mobile supports Android 11. For more details, see Android 11: Modifying the behavior of applications.
Overview
After each new version of Android is deployed, Google requires a higher target API level ("TargetSdkVersion") to publish applications on Google Play. With the release of Android 10, Google now requires API level 29 to allow deployments. This new API level applies from:
  • 3 August 2020 for new applications,
  • 2 November 2020 for application updates.
These are the changes that apply to applications:
  1. On Android 10
    • When the application is in the background, it is no longer possible to open a window. For more details, see Behavior of applications in the background.
    • It is no longer possible to get a unique device identifier with SysIMEI and SysSerialNum. "Device owner" applications are not affected by this restriction.
    • It is no longer possible to manipulate WiFi connection parameters through programming. The following functions trigger a fatal error when used in Android 10 or higher: WiFiActivate (syntax to modify activation only), WiFiAddNetwork, WiFiDeleteNetwork, WiFiConnect and WiFiListNetwork.
      "Device owner" applications are not affected by this restriction.
    • It is no longer possible to get the clipboard contents if the application is in the background.. In this case, Clipboard will return an empty string.
  2. On Android 10 with API level 29:
    • Applications can no longer access files located on the external storage, outside their specific directories (SysDirExternalStorage with sseApp* constants).
      These files can no longer be accessed in read or write mode. Hard-coded file paths or paths built from SysDirStorageCard or SysDirExternalStorage with ssePublicxxx constants should no longer be used. This restriction will be permanent from Android 11, API level 30. On Android 10 (API level 29), some of these locations remain accessible, so they can be used with this version of WINDEV Mobile (to do so, the requestLegacyExternalStorage attribute is automatically added). However, it is recommended to make the necessary adaptations to the applications that access these locations.
    • Android 10 has implemented a new permission for the functions that allow locating the device: ACCESS_BACKGROUND_LOCATION.
      This permission is automatically added when one of the following functions is used in the application to allow its use in the background:
      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.
      geoTrackingEnableEnables the management of location tracking in a WINDEV Mobile application.
      GPSDetectPositionAsks to be notified when the device gets close to a given location.
      GPSFollowMovementRequests to be notified periodically of the device's current location.
      GPSGetPositionRetrieves information about the current device position.
      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.
      GPSLastPositionRetrieves the information about the last known device position.
      GPSStatusRetrieves the activation status of the geolocation provider or asks to be notified when the status changes.
      GPSStopDetectionStops the location detection triggered by GPSDetectPosition.
      MapFollowMovementDisplays the current location of the device in a Map control and updates the location as it moves.
      MobileNetworkConnectionInfoReturns information regarding the current connection to data on the mobile network.
      WiFiDetectAccessPointStarts detecting the Wi-Fi access points currently accessible from the device.
      When this permission is added to the application, the user can grant access to the device's location when the application is in the background, only when the application is in use, or deny the access. The user can also change these permissions at any time in the Android settings.
Remark: The following error may appear when publishing an application on the Play Store: "The private key was not properly encrypted or is not a type of key we support". It is necessary to recreate the signature file of the application (this file can be recreated in the application generation wizard).
Caution: If there are identifiers based on the signature file (e.g. Google Map identifier), it is also necessary to regenerate these identifiers with the new key.

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.
This API level can also be modified. This means that it is possible to specify target API level 29 in a WINDEV Mobile application generated without update 118 661. But in this case the application will not have a framework adapted to the specifics of this API level. This solution should therefore be avoided, since Android will apply security rules different from those for which the application has been tested.
For more details, see Google's website.
Behavior of applications in the background

Overview

From Android 10, Google no longer allows an application running in the background to open a window (Activity) https://developer.android.com/guide/components/activities/background-starts. This is a very important change that affects all Android applications, including those generated with WINDEV Mobile. "Device owner" applications are the only exception. In this specific mode, apps can still open a window.
An application that ran properly in all Android versions prior to 10 will therefore have limitations if it is installed on Android 10:
  • when the application is running in the background, it is not possible to open a window (OpenMobileWindow, Info, Error, Dialog, etc.),
  • a WLanguage function that opens a window can no longer be used (SMSRunApp, etc.),
  • the Android framework of the application will also be blocked and will not be able to open a window from the background. Opening a background window via the framework is necessary to manage the following functionalities:
    • receiving a push notification,
    • detecting entry or exit from a beacon region (BeaconDetectBackground),
    • receiving a new position when position tracking is enabled (geoTrackingProcedure),
    • running tasks in the background (BackgroundTaskxxx functions).
    • running the application when the Android device is started.
These limitations apply to all applications generated with WINDEV Mobile 25 "Update 2" and earlier versions.

Changes from WINDEV Mobile 25 Update 3

The Android framework of WINDEV Mobile applications has been modified to take into account this requirement from Google. All necessary adaptations are included from WINDEV Mobile 25 Update 3 onwards.
From WINDEV Mobile 25 Update 3, push notifications, position tracking, beacon detection, ... are restored. Additionally, the WLanguage security mechanism has been improved to trigger a fatal error if a function that opens a window is called when the application is in the background (see list of relevant functions).
In order to make sure that an application runs properly on Android 10, you need to:
  • use at least WINDEV Mobile 25 Update 3 to generate it,
  • check all processes that can be run from the application in the background: these processes must not open a window. To optimize your code, you can:
    • use InBackgroundMode to determine if the current process is running in the background.
    • use ExeInfo to know if the application is launched when the device boots up. In this case, if this function is called with the exeLaunch constant as parameter, it will return the exeStartup constant.
    • If an application needs to interact with the user while it is in the background, the recommended solution is to display a notification. When the notification is clicked on, the application will be brought back to the foreground and will be allowed to open a window from the procedure called with the ActionClick property (the ActivateApplication property of the Notification variable must be set to True).
  • when fine-tuning the application on an Android device, use the Android log to identify the origin of a possible crash during background execution. Since a window cannot be opened from the background, the WLanguage security mechanism cannot transmit any information. Errors are logged in the Android log.

List of related functions

The following functions trigger a fatal error if a call is made from a code run in the background:
AlbumPickerRetrieves a photo, an image or a video stored in the photo album of the mobile device.
AppointmentCreateDisplays the window for appointment creation of native application for managing appointments found on the Android device.
AppointmentDisplayDisplays an appointment in the native application for managing appointments found on the mobile device (Android or iOS).
AppOpenFormOpens:
  • the form of an application on Android (Play Store), iOS (App Store) or Windows (Windows Store) in order for the user to give a mark to it and/or to comment it.
  • the form for configuring the In-App purchases of an application.
AuthIdentifyPerforms an authentication using the OAuth 2.0 protocol on any web service.
BCCaptureDecodes the information stored in a bar code by using the device camera (Android, iPhone, iPad).
BTChangeVisibilityChanges the visibility of a Bluetooth radio.
CheckUserIDentityChecks the identity of the current user using biometric authentication.
ConfirmDisplays a message in a standard dialog box that proposes "Yes", "No", "Cancel" and returns the user's choice.
ConfirmAsynchronousDisplays a non-blocking message in a standard dialog box with the answers "Yes", "No", "Cancel" and calls a WLanguage procedure with the user's response.
ContactCreateDisplays the window for contact creation of the native application for contact management found on the device (Android, iPhone or iPad, Universal Windows).
ContactDisplayOpens the form of a contact in the device's native contacts application (Android, iPhone or iPad, Universal Windows).
ContactEditOpens the form of a contact in edit mode in the device's native contacts application (Android, iPhone, iPad, Universal Windows).
ContactSelectDisplays the list of contacts found on the device (Android, iPhone or iPad, Universal Windows).
DatePickerOpens the system date picker.
DialogDisplays a message box and returns the value of the button clicked by the user.
DialogAsynchronousDisplays a non-blocking message box and calls a WLanguage procedure with the value of the button clicked by the user.
EmailOpenMailOpens the default messaging software:
  • of Web user on the browser computer.
  • of the user on the current Windows computer.
  • on the phone.
EmailRunAppStarts the native application for sending emails found on the current computer:
  • Computer running Windows,
  • Mobile device (Android, iPhone, iPad).
ErrorDisplays a custom error message in a system error window.
ErrorAsynchronousDisplays a custom error message in a non-blocking system error window.
ErrorBuildDisplays a custom error message in a system error window.
ExeRunExecutes a program (an executable file, for example) from the current application.
FBStartSessionUsed to authenticate and log in to Faceboook.
geoRunAppStarts the device's native maps application to display:
  • a specific geographical location,
  • a route between two locations.
GglPrintDocumentPrints a document (text or PDF file, images, Word or Excel document, ...) by using the Cloud Print service of Google.
gpwAuthLoginAllows you to connect to the User Groupware using authentication with an account such as Facebook, Google, Microsoft, etc.
inAppPurchaseProductSends a request for purchasing an "In-App" product associated with the application.
InfoDisplays a custom message in a system information window.
InfoAsynchronousDisplays a non-blocking custom message in a system information window.
InfoBuildDisplays a custom message in a system information window.
InputDisplays a message allowing the user to type an information.
KioskDisableDisables kiosk mode for the current application.
KioskEnableSwitches the current Android application to kiosk mode.
NFCReadTagStarts reading a NFC tag or enables the detection of NFC tags for the current window.
NFCSendTagSends a NFC tag to another device.
NFCWriteTagStarts writing data to an NFC tag.
OKCancelDisplays a message in a standard dialog box that proposes "OK" and "Cancel" and returns the user's choice.
OKCancelAsynchronousDisplays a message in a standard non-blocking dialog box with the answers "OK" and "Cancel" and calls a WLanguage procedure with the user's response.
OpenMobileWindowOpens a window in a mobile application.
ShellExecuteOpens a document in its associated application.
SMSRunAppStarts the native application for sending SMSs found on the device (Android or iPhone/iPad).
SpeechRecognitionTriggerTriggers the device's speech recognition service.
SpeechSynthesisInitializeInitializes the parameters of speech synthesis for the current application.
SpeechSynthesisReadFileReads the content of the specified file by using the engine for speech synthesis found on the device.
SpeechSynthesisReadTextReads the specified text using the device's text-to-speech engine.
StartShareOpens a popup allowing you to select the application that will be used to share a resource (text or document).
SysBatteryOptimBackgroundUsed to manage battery optimization:
  • Identifies the battery optimization mode for the current application.
  • Prompts the user to disable battery optimization for a given application on the device.
This function can be used to tell the operating system to stop preventing the application from running in the background.
tapiDialerCallOpens the default telephony application (dialer) found on the phone and dials the specified number.
tapiDialerDisplayOpens the default telephony application (dialer) and displays the specified number. No call is made.
TimePickerOpens the system time picker.
URISelectOpens a system window to select a resource from:
  • from the device file system,
  • from the Cloud (Google Drive, Microsoft OneDrive, etc.)
  • or from one of the content managers installed on the device.
VideoStartAppStarts the device's native camera application to record a video or to take a photo.
WarningDisplays a custom message in a system warning window.
WarningAsynchronousDisplays a custom message in a non-blocking system warning window.
YesNoDisplays a message in a standard dialog box that proposes "Yes" and "No" and returns the user's choice.
YesNoAsynchronousDisplays a message in a standard non-blocking dialog box with the answers "Yes" and "No" and calls a WLanguage procedure with the user's response.
Minimum version required
  • Version 25
Comments
Click [Add] to post a comment

Last update: 01/26/2023

Send a report | Local help