问题
I am trying to make sensors work when screen is off. It is well known bug. And there is no any soution for this on all phones. I have the hypothesis that i can can cheat kernel if I send(inject) screen_on event while actually the screen will be turned off. Do you have any ideas how can i check my hypothesis and inject such event?
回答1:
Why don't you start a background service that monitors the sensors?
And then send/use the results back to your application's activities. Your activity will still pause when screen goes off, but you will continue to read the sensor data.
Also a good idea to do the heavy processing the background service as well...
This works great for me.
来源:https://stackoverflow.com/questions/11987510/injecting-screen-on-event-to-make-sensors-work-when-screen-is-off