C Carlo2015 Member Licensed User Longtime User Jul 1, 2018 #1 Please help guys. I dont know why but the code below wont run on other phones but runs perfectly well on my asus zenfone 2. Code: Copy Sub Process_Globals Dim myNotification As Notification End Sub Code: Copy Sub Service_Create myNotification.Initialize myNotification.Icon = "logo" myNotification.Sound = False myNotification.Vibrate = False myNotification.SetInfo("Title", "Message",Main) myNotification.Notify(10000) Code: Copy Sub Service_Start (StartingIntent As Intent) Service.StartForeground(10000, myNotification) End Sub When omitted the app runs well on 2 other phones (Vivo and SOny Experia). I need the app to NOT die when installed as this is a GPS app that updates coordinates every 10 mins. Code: Copy #StartCommandReturnValue: android.app.Service.START_STICKY does not work. when the phone locks the service stops. EDIT: this are my libs Last edited: Jul 1, 2018
Please help guys. I dont know why but the code below wont run on other phones but runs perfectly well on my asus zenfone 2. Code: Copy Sub Process_Globals Dim myNotification As Notification End Sub Code: Copy Sub Service_Create myNotification.Initialize myNotification.Icon = "logo" myNotification.Sound = False myNotification.Vibrate = False myNotification.SetInfo("Title", "Message",Main) myNotification.Notify(10000) Code: Copy Sub Service_Start (StartingIntent As Intent) Service.StartForeground(10000, myNotification) End Sub When omitted the app runs well on 2 other phones (Vivo and SOny Experia). I need the app to NOT die when installed as this is a GPS app that updates coordinates every 10 mins. Code: Copy #StartCommandReturnValue: android.app.Service.START_STICKY does not work. when the phone locks the service stops. EDIT: this are my libs
Erel B4X founder Staff member Licensed User Longtime User Jul 1, 2018 #2 Don't use sticky services. They don't do anything useful in newer versions of Android. 1. It is better to move all this code to Service_Start. Reusing notification objects can fail. 2. You need to also acquire a partial lock with PhoneWakeState if you want the process to keep running. Upvote 0
Don't use sticky services. They don't do anything useful in newer versions of Android. 1. It is better to move all this code to Service_Start. Reusing notification objects can fail. 2. You need to also acquire a partial lock with PhoneWakeState if you want the process to keep running.
C Carlo2015 Member Licensed User Longtime User Jul 1, 2018 #3 hi erel, thanks for the reply. i change the whoel code to just Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS on service_create and it worked well now. sorry for the late update as i tested it yet before confirming it here. it took me 1 hour to test. had the phone locked for the whole duration and it still sends update. thanks Upvote 0
hi erel, thanks for the reply. i change the whoel code to just Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS on service_create and it worked well now. sorry for the late update as i tested it yet before confirming it here. it took me 1 hour to test. had the phone locked for the whole duration and it still sends update. thanks