tchart Well-Known Member Licensed User Longtime User Jul 28, 2014 #1 Im trying to write an app that performs an action when the phone receives an SMS with a specific command text. Ive got the background service running fine and the SMS is picked up correctly. Im got it logging to a file as well so I can confirm everything is happening. The phone is permanently in a dock so is powered but maybe "sleeping". I've disabled any wifi sleep & power saving options. The problem Im having is that the the action the phone takes (sending a UDP packet over the wifi connection) is sporadically successful. Im not sure if what Im doing it right. 1) Service intercepts SMS 2) Message is parsed and added to "stack" of commands 3) Timer enabled 4) For each timer tick check device has an WiFi IP and sends the command 5) If no more messages stop the timer I note that the timer runs on the UI thread, is this a problem for service modules? My log file indicates everything is working but I'm seeing odd results in the real world.
Im trying to write an app that performs an action when the phone receives an SMS with a specific command text. Ive got the background service running fine and the SMS is picked up correctly. Im got it logging to a file as well so I can confirm everything is happening. The phone is permanently in a dock so is powered but maybe "sleeping". I've disabled any wifi sleep & power saving options. The problem Im having is that the the action the phone takes (sending a UDP packet over the wifi connection) is sporadically successful. Im not sure if what Im doing it right. 1) Service intercepts SMS 2) Message is parsed and added to "stack" of commands 3) Timer enabled 4) For each timer tick check device has an WiFi IP and sends the command 5) If no more messages stop the timer I note that the timer runs on the UI thread, is this a problem for service modules? My log file indicates everything is working but I'm seeing odd results in the real world.
Erel B4X founder Staff member Licensed User Longtime User Jul 29, 2014 #2 Make sure to read this tutorial: Intent Filters - Intercepting SMS messages in the background Android may kill the process after it is waked. Acquire a partial lock with PhoneWakeState and release it when the task is complete. Upvote 0
Make sure to read this tutorial: Intent Filters - Intercepting SMS messages in the background Android may kill the process after it is waked. Acquire a partial lock with PhoneWakeState and release it when the task is complete.