JohnC Expert Licensed User Longtime User Oct 26, 2022 #1 I need to keep an Android TV service running all the time and have some questions: 1) I am thinking of including "Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS" mode/setting as mentioned in https://www.b4x.com/android/forum/threads/automatic-foreground-mode.90546 The app will be running on devices running API 28+, but in order for a particular feature of the app to work correctly, I need to set the targetSDK=22. So, will setting the foreground mode work on a device running API 28+ but with the manifest set to targetSDK=22? 2) Should I still do a PhoneWakeState.PartialLock even if the TV will stay powered on - is there any harm in including this line anyway? 3) Should/can I combine #StartCommandReturnValue: android.app.Service.START_STICKY with Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS What would be the best practice to keep a service (foreground) running 24/7? I am asking because when I use just the sticky option (using the default foreground setting), some users have reported the app gets killed. Last edited: Oct 27, 2022
I need to keep an Android TV service running all the time and have some questions: 1) I am thinking of including "Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS" mode/setting as mentioned in https://www.b4x.com/android/forum/threads/automatic-foreground-mode.90546 The app will be running on devices running API 28+, but in order for a particular feature of the app to work correctly, I need to set the targetSDK=22. So, will setting the foreground mode work on a device running API 28+ but with the manifest set to targetSDK=22? 2) Should I still do a PhoneWakeState.PartialLock even if the TV will stay powered on - is there any harm in including this line anyway? 3) Should/can I combine #StartCommandReturnValue: android.app.Service.START_STICKY with Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS What would be the best practice to keep a service (foreground) running 24/7? I am asking because when I use just the sticky option (using the default foreground setting), some users have reported the app gets killed.
Erel B4X founder Staff member Licensed User Longtime User Oct 27, 2022 #2 The relevant example is this one: https://www.b4x.com/android/forum/threads/99873/#content I wouldn't use sticky services. It is a thing of the past. 2) no harm. Upvote 0
The relevant example is this one: https://www.b4x.com/android/forum/threads/99873/#content I wouldn't use sticky services. It is a thing of the past. 2) no harm.