I'm in the process of converting an old app I wrote (around B4A v10 or so) whose sole purpose is to query a back-end API every 15 minutes and if any issues are detected/reported with the API it uses NB6 to raise an alert. Currently it has 1 alert icon to indicate it's running (waiting for the next StartServceAt(...) and a separate NB6 icon for "Huston, we have problems."
This app worked fine for years until the latest Android OS update (14). Now, the OS will randomly kill the app even with power-saving off so I decided I'd try re-writing in B4XPages/Receivers even though it's strictly Android.
The app is for personal use and is NOT part of Google (Play). The way the app is currently structured, the "monitoring" is in a service, and it relies on many public variables in the Starter service. The monitor service has a few public subs that activities can call, and if it detects it was started with android.intent.extra.ALARM_COUNT it will show the NB6 notification if a problem is detected, otherwise not (the Activity will handle message notification).
I've read so many posts about problems with services, receivers, what's initialized, what's not initialized, if you can start another service or not, etc., etc., it's hard to tell what path to take. Even Erel's Post on it was somewhat nebulous about design methodology other than "service = continuous process, receiver = short process." The post doesn't explain the receiver life-cycle or how it should interact with the rest of the app.
Given this methodology and everything (wrong, LOL) with Android 14, can someone please suggest which course of action would be best in my use-case? Should I keep it a service and try to find some permission set that will allow it to run as it did before, or is there some design methodology where I can make it a Receiver and not have to duplicate the Starter service code to load credentials, etc.?
This app worked fine for years until the latest Android OS update (14). Now, the OS will randomly kill the app even with power-saving off so I decided I'd try re-writing in B4XPages/Receivers even though it's strictly Android.
The app is for personal use and is NOT part of Google (Play). The way the app is currently structured, the "monitoring" is in a service, and it relies on many public variables in the Starter service. The monitor service has a few public subs that activities can call, and if it detects it was started with android.intent.extra.ALARM_COUNT it will show the NB6 notification if a problem is detected, otherwise not (the Activity will handle message notification).
I've read so many posts about problems with services, receivers, what's initialized, what's not initialized, if you can start another service or not, etc., etc., it's hard to tell what path to take. Even Erel's Post on it was somewhat nebulous about design methodology other than "service = continuous process, receiver = short process." The post doesn't explain the receiver life-cycle or how it should interact with the rest of the app.
Given this methodology and everything (wrong, LOL) with Android 14, can someone please suggest which course of action would be best in my use-case? Should I keep it a service and try to find some permission set that will allow it to run as it did before, or is there some design methodology where I can make it a Receiver and not have to duplicate the Starter service code to load credentials, etc.?