|
Post by nathanmyersc on Sept 30, 2024 7:20:43 GMT
I managed to make the WIFIBROADCASTER i made for the android have a foreground service that did the packet sending. This service services even if the application times out is reclaimd or you exit it. And the next time you start the app it gets information from shared preferences and continues getting updates from the broadcast service. I feel the same thing could be done with your application so that it doesnt randomly exit if someone was using other applications after starting it.
Im pretty sure it would be as simple as not destroying the service on destruction. And making the mainActivity responsible for changing the UI and it recieves updates from the service as to its total iterations and frequency and time. And you could store the intention and other settings in a shared preference so upon loading it would still be in the same state as if the application was never closed by the phone itself.
|
|
|
Post by AnthroHeart on Sept 30, 2024 13:11:38 GMT
I managed to make the WIFIBROADCASTER i made for the android have a foreground service that did the packet sending. This service services even if the application times out is reclaimd or you exit it. And the next time you start the app it gets information from shared preferences and continues getting updates from the broadcast service. I feel the same thing could be done with your application so that it doesnt randomly exit if someone was using other applications after starting it. Im pretty sure it would be as simple as not destroying the service on destruction. And making the mainActivity responsible for changing the UI and it recieves updates from the service as to its total iterations and frequency and time. And you could store the intention and other settings in a shared preference so upon loading it would still be in the same state as if the application was never closed by the phone itself. It should allow you running when using other apps. The app uses a wakelock which should keep it going when in the background.
Android kills services it deems not essential after a bit it seems.
|
|
|
Post by AnthroHeart on Sept 30, 2024 15:01:07 GMT
|
|
|
Post by nathanmyersc on Oct 1, 2024 0:27:59 GMT
Yeah i know. But you can make it so that the foreground service doesnt close when the app times out. And it would keep going. you could make it so that when you restart the app it gets sharedpref data and data from the foreground service to keep displaying the iterations and the current intention. Look at my app as an example. you can exit the app and restart it and it will still be running. Like you can end the task of the app and the foreground service doesnt end. Albiet running the intention and timer from a service is slower than running it from an activity.
|
|
|
Post by AnthroHeart on Oct 1, 2024 0:32:51 GMT
I don't really have a desire to make it continue running when app is closed and then restarted.
|
|
|
Post by nathanmyersc on Oct 1, 2024 2:36:00 GMT
I don't really have a desire to make it continue running when app is closed and then restarted. Perhaps you just havent encountered the problem i have of it constantly being reclaimed for memory or whatever. if i alt tab from it it always ends up closing.
|
|
|
Post by reden on Oct 1, 2024 2:38:20 GMT
I don't really have a desire to make it continue running when app is closed and then restarted. Perhaps you just havent encountered the problem i have of it constantly being reclaimed for memory or whatever. if i alt tab from it it always ends up closing. How much ram does your phone have? Mine has 4, and I have to juggle a little sometimes to keep it from being closed, specially for when I want to play a game (close chrome), but so far my longest runtime is 23 hours.
|
|
|
Post by AnthroHeart on Oct 1, 2024 13:30:30 GMT
I don't really have a desire to make it continue running when app is closed and then restarted. Perhaps you just havent encountered the problem i have of it constantly being reclaimed for memory or whatever. if i alt tab from it it always ends up closing. Try running with Multiplier 0 so it uses much less RAM.
I don't have a problem on my Galaxy S24+.
|
|