Android Question B4XPages stop in background on android 15

I have a B4XPages application that I use with different package names simultaneously on my phone and in Android 13 they all work in the background without interruption without any problems.
But in Android 15 only the one that was selected last, works in the background and the others stop until I select them and as soon as I select them they start working from where they stopped. Please advise what I can do to fix this problem.
manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="33"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
SetServiceAttribute(alive, android:foregroundServiceType, "location")
AddPermission(android.permission.VIBRATE)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(android.permission.FOREGROUND_SERVICE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.NETWORK)
AddPermission(android.permission.ACCESS_SUPERUSER)
AddPermission(android.permission.WRITE_SETTINGS)
AddPermission(android.permission.QUERY_ALL_PACKAGES)
AddPermission(android.permission.REORDER_TASKS)
AddPermission(android.permission.GET_TASKS)
AddPermission(android.permission.PACKAGE_USAGE_STATS)
AddPermission(android.permission.ACCESS_WIFI_STATE)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.BIND_VPN_SERVICE)
AddApplicationText(
<service android:name="com.b4xcode.proxyclient.LocalVpnService"
   android:label="B4XCode Proxy Service"
   android:exported="false"
  android:permission="android.permission.BIND_VPN_SERVICE">
  <intent-filter>
  <action android:name="android.net.VpnService" />
  </intent-filter>
</service>)

AddManifestText(<uses-permission android:name="mohsen.eitaaadv.broadcast_permission"/>)
AddManifestText(<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/>)
SetApplicationAttribute(android:usesCleartextTraffic,"true")
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
CreateResourceFromFile(Macro, Core.NetworkClearText)
'SetServiceAttribute(jobs, android:foregroundServiceType, "location")
AddApplicationText(
<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />
)
SetApplicationAttribute(android:networkSecurityConfig, @xml/network_security_config)
CreateResource(xml, network_security_config.xml,
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
)
AddPermission(android.permission.DOWNLOAD_WITHOUT_NOTIFICATION)
'---------------------
AddManifestText(<uses-feature android:name="android.hardware.telephony" android:required="false" />)
 
I have no problem with running the program in the background. Because it works, but when I run another program, the previous program stops. For example, the timer stops.
 
Upvote 0
From what I've checked, the problem isn't just with Android 15. Because the same app works without any problems on the Poco X6 Pro with Android 15, but it stops on the Poco X7 Pro with the same version of Android.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
As Erel have said, that's the normal behaviour of android, and you should use a foreground service. The strange thing is not that your app stops now in some devices with Android 15, but it didn't stop on previous versions without a service. If the os need it, it will stop any app in the background (to save memory, or battery...). If you need to run your apps in background, then you need a foreground service.
 
Upvote 0
Top