1

I'm developing an application that start a service to execute an action when the ambient light changes. Here is the cinematic:

 Activity A
    On Start --> If Service S running, start Activity B 
    On Click --> Start Service S (not an IntentService) using starService. 
 Activity B 
    On Start --> Bind to Service S 
    On Click --> Stop Service S 
 Service S implements SensorEventListener 
    On Create --> Register to light sensor 
    On Sensor Changed --> Write a log 
    On Destroy --> Unregister to light sensor 

My problem is: When you launch the application and start the service, everything is fine. When the screen is turned off, Service S does not receive notifications from the light sensor anymore. When I turn the screen back on, no notifications are received either. If I destroy the Service and start it again within the same application session, notification are not received.

Documentation on sensor are not very helpful (or maybe I missed something). Can anyone help?

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
SomeGuy
  • 19
  • 4
  • see my answer in http://stackoverflow.com/questions/31162516/why-onsensorchange-is-not-invoked-when-wearable-device-is-in-ambient-mode/38324733#38324733 –  Jul 12 '16 at 10:20

0 Answers0