- Dec 12, 2022
- 357
- 2
I'm trying to keep my app, or at least the service it spawns, alive - at least overnight. My phones (Honor 8x (android 9)) is very good at killing off services and applications. As per tutorials I've used phoneWakeState.PartialLock and also startServiceAt along with Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER followed by Service.StartForeground(nid, CreateNotification("..."))
My app comprises a 'start' Button in the Main GUI which starts a service (started in foreground mode, with a notification) and this service, every 10 minutes, starts a temporary 'worker' that happens to talk to a bluetooth controlled relay. This worker service kills itself off after every call (it runs less than a minute).
My question is, where should the phoneWakeState.PartialLock be coded? In the Main or in the foreground service? Or both?
My experiments show that startServiceAt is largely ignored as the phone sleeps and I see that Erel's GPS example has removed it. (I think -...
My app comprises a 'start' Button in the Main GUI which starts a service (started in foreground mode, with a notification) and this service, every 10 minutes, starts a temporary 'worker' that happens to talk to a bluetooth controlled relay. This worker service kills itself off after every call (it runs less than a minute).
My question is, where should the phoneWakeState.PartialLock be coded? In the Main or in the foreground service? Or both?
My experiments show that startServiceAt is largely ignored as the phone sleeps and I see that Erel's GPS example has removed it. (I think -...
برای دیدن لینک ها باید ثبت نام کنید
برای دیدن لینک ها باید ثبت نام کنید