android.intent.action.SCREEN_ON doesn't work as a receiver intent filter

前端 未结 3 1109
Happy的楠姐
Happy的楠姐 2020-11-29 08:00

I\'m trying to get a BroadcastReceiver invoked when the screen is turned on. In my AndroidManifest.xml I have specified :

                

        
3条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 08:35

    Following sage advice from CommonsWare I have elected to try to remove the long-living Service and use different techniques.

    Actually, I believe my advice was more of a light blue... :-)

    But I still need to detect the screen off and on events.

    There are certain events that Android does not want to start up new processes for, so the device does not get too slow from all sorts of stuff all having to run at once. ACTION_SCREEN_ON is one of those. See this previous question for light blue advice on that topic.

    So, you need to ask yourself, "Self, do I really need to get control on those events?". The core Android team would like it if your answer was "no".

提交回复
热议问题