J Jonathan Rigley Member Licensed User Longtime User Jan 7, 2015 #1 Hi, I use : Code: Copy StartServiceAt(svcAlarm, DateTime.Now, True) and Sticky Service to start a service. The service looks through a database for the current date and time. If found it starts an activity. I know the database is looking because I've used ToastMessageShow to show the service is running. If the phone screen is on the alarm activates but if the phone screen is off it doesnt work. Ive tried: Code: Copy Dim oPhoneWakeState As PhoneWakeState oPhoneWakeState.ReleaseKeepAlive oPhoneWakeState.KeepAlive(True) To wake the phone but no luck. Can any one help? Jonathan
Hi, I use : Code: Copy StartServiceAt(svcAlarm, DateTime.Now, True) and Sticky Service to start a service. The service looks through a database for the current date and time. If found it starts an activity. I know the database is looking because I've used ToastMessageShow to show the service is running. If the phone screen is on the alarm activates but if the phone screen is off it doesnt work. Ive tried: Code: Copy Dim oPhoneWakeState As PhoneWakeState oPhoneWakeState.ReleaseKeepAlive oPhoneWakeState.KeepAlive(True) To wake the phone but no luck. Can any one help? Jonathan
Erel B4X founder Staff member Licensed User Longtime User Jan 8, 2015 #2 Check the logs while the screen is off to see whether the service is started or not. Upvote 0
J Jonathan Rigley Member Licensed User Longtime User Jan 8, 2015 #3 Hi Erel, thanks for replying. The service is running with the screen off. The strange thing is. Whilst connected to B4A all works well but as soon as I disconnect the wireless it won't fire the alarm. My guess is because B4A keeps the phone awake. Jonathan Upvote 0
Hi Erel, thanks for replying. The service is running with the screen off. The strange thing is. Whilst connected to B4A all works well but as soon as I disconnect the wireless it won't fire the alarm. My guess is because B4A keeps the phone awake. Jonathan
Chandrashekhar Member Licensed User Longtime User Jan 8, 2015 #4 I use following modifided code from erel's showwhenlocked to wakeup my device if its screen off. Hope its help you. Code: Copy Dim r As Reflector Log("set") r.Target = r.GetActivity r.Target = r.RunMethod("getWindow") r.RunMethod2("addFlags", 524288, "java.lang.int") Upvote 0
I use following modifided code from erel's showwhenlocked to wakeup my device if its screen off. Hope its help you. Code: Copy Dim r As Reflector Log("set") r.Target = r.GetActivity r.Target = r.RunMethod("getWindow") r.RunMethod2("addFlags", 524288, "java.lang.int")
J Jonathan Rigley Member Licensed User Longtime User Jan 8, 2015 #5 Thank you for your reply, I tried the above code but it didn't work for me. It's as if the service stops running. I've also tried Service.StartForeground but to no avail. Jonathan Upvote 0
Thank you for your reply, I tried the above code but it didn't work for me. It's as if the service stops running. I've also tried Service.StartForeground but to no avail. Jonathan
Erel B4X founder Staff member Licensed User Longtime User Jan 9, 2015 #6 PhoneWakeState.KeepAlive should turn on the screen. Maybe your device prevents the screen from waking to preserve battery. Upvote 0
PhoneWakeState.KeepAlive should turn on the screen. Maybe your device prevents the screen from waking to preserve battery.
J Jonathan Rigley Member Licensed User Longtime User Jan 11, 2015 #7 Just for information: I started a separate application with a service containing a 30 second timer. The timer contained PhoneWakeState and a 1 second vibrate. I started the service with StartServiceAt(svcStartAlarm, DateTime.Now, True) and made it a sticky service. I ran the app and switched the phone off. It work for about 4 minutes then stopped working. I tried Service.StartForeground but this only worked for a minute before stopping. These have been run on a factory reset Samsung Galaxy s5 with kitkat. Its my best guess that the service is being killed. Jonathan Upvote 0
Just for information: I started a separate application with a service containing a 30 second timer. The timer contained PhoneWakeState and a 1 second vibrate. I started the service with StartServiceAt(svcStartAlarm, DateTime.Now, True) and made it a sticky service. I ran the app and switched the phone off. It work for about 4 minutes then stopped working. I tried Service.StartForeground but this only worked for a minute before stopping. These have been run on a factory reset Samsung Galaxy s5 with kitkat. Its my best guess that the service is being killed. Jonathan
Erel B4X founder Staff member Licensed User Longtime User Jan 11, 2015 #8 You can use StartServiceAt to rerun your service every few minutes. This will cause it to start again if the process was killed. Upvote 0
You can use StartServiceAt to rerun your service every few minutes. This will cause it to start again if the process was killed.
J Jonathan Rigley Member Licensed User Longtime User Jan 14, 2015 #9 Thanks Erel, that worked perfect on my daughters S3 but still not on mine. Thinking this could be an android issue or bug. Thank you for your help. Upvote 0
Thanks Erel, that worked perfect on my daughters S3 but still not on mine. Thinking this could be an android issue or bug. Thank you for your help.