Android broadcast receiver doesn't receive ACTION_SCREEN_ON

后端 未结 3 1198
一生所求
一生所求 2020-12-17 05:36

I tried to register the receiver in my service with the following code:

IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
ScreenReceiver SR =         


        
3条回答
  •  青春惊慌失措
    2020-12-17 06:10

    Maybe you should check which intent is coming inside your onReceive() method:

    if(intent.getAction().equals(Intent.ACTION_SCREEN_ON)
    {
        ...
    }
    

    Also, have you tried putting a breakpoint in there?

    Other advice, instead of using System.out.println use the API native log which would be in your case

    Log.i("ScreenReceiver""RECEIVED");
    

    And you can read the log in the logcat.

提交回复
热议问题