The key is to use a Foreground service to prevent Doze mode. And the MediaNotification extension does that too (even on Android 14 under targetSdk 34).
I loaded "UrsMediaNotification.aia", then I modified it adding Texting block and GPS block.
Tested on Android 14 - Samsung A23.
APP sent SMSs after screen was off also.
But SMS receiver stopped and GPS stopped when screen went off.
So, with screen off, I always received the last LAT+LON taken when screen was on.
GPStest.aia (1.0 MB)
Use ITOO Background extension, and your needs are fulfilled after close or after in the foreground.
You might want to explain, what your app is about. Then we can suggest, what to do.
Are you trying to get location data while your app is running in the background? App Inventor Extensions: Location Service | Pura Vida Apps
Are you trying to do something after an sms has been received? App Inventor Extensions: SMS Receiver | Pura Vida Apps
Taifun
I need to get location data in background and to send these data through Texting component.
Probably your extensions Locations Service and SMS receiver could do the job
Ok, I'll try this trick also
Use the locationservice extension to receive location data in the background
To send an sms is only possible in the foreground
EDIT: you could also use an API to send sms in the background, for example Twilio... SMS API | Twilio
The locationservice extension offers an interface to itoo, so you could use itoo to connect to an API in the background
Taifun
To get location data in the background you need background location permission
The locationservice extension is able to do it
What exactly means "manage texting events"?
Texting events do not work in the background together with itoo, this is why I prepared my sms-receiver extension.... however earlier you mentioned, you like to send sms in the background?
Taifun
Hi Taifun,
I would like to create a GPS tracker that sends GPS position through SMS (or loading data to a web server) and can be activated sending an SMS to the tracker.
Probably your extensions (LocationService and sms-receiver) are actually the only effective solution
As already suggested
or store the data on your web server
Use the sms-receiver extension to activate it
Taifun
In your test aia you use a WakeLock extension that declares REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
in the Manifest. An app that has this permission declared in the Manifest will not be allowed in the Play Store (without Google's approval).
No problem, I think only few of my apps could be on Play Store.....
The problem is perhaps that there is little discipline in this thread. People post about all sorts of things here. The important posts are then overlooked. From 2024-09-11:
Hi, I made an update for the KeepAlive extension. But I can't test it. My best phone has Android 13.
Please download the new version from https://ullisroboterseite.de/_forDownload/de.ullisroboterseite.ursai2keepalive.aix and report back whether it works.
The version on my site is not updated!
Tested Extension Ver.1.11.0 on Android 14 (SDK 34) using "URS Keep Alive Sevice Test" app.
After pressing "Start Keep Alive Service" the application hungs
Please disable the WakeLock to make shure that KeepAlive is the problem:
As I already said in my email to you, I used your test app and updated the new extension version there. The app crashes/freezes on Android 14 devices. I also removed all other extensions (WakeLock, UDPSender) - without success.
Unfortunately, we don't have the source code of the new extension yet to find out where the problem might be. (The new MediaNotification ext. seems to work fine on Android 14+.)
Done, disabled Wakelock blocks
The app stucks in the same way
I found a more in-depth guide to the Foreground service and realized that I hadn't made a necessary change.
You can download the extension, the current source code and a reduced example from this link: https://ullisroboterseite.de/_forDownload/Update-UrsAI2KeepAlive.zip
This are the modifications:
In the service declaration for the manifest parameter "foregroundServiceType" was added (file UrsAI2KeepAlive.java):
@UsesServices(services = {
@ServiceElement(name = "de.ullisroboterseite.ursai2keepalive.UrsService", enabled = "true", exported = "true", foregroundServiceType = "specialUse") })
In file UrsService.java making the service a foreground service parameter "foregroundServiceType" was added:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(notificationID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
} else {
startForeground(notificationID, notification);
}