Reputation: 4740
I have created a BroadcastReceiver
that should listen for the "ACTION_SCREEN_OFF" intent.
public class ExampleReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// run a service..
}
}
I have registered it in the Manifest:
<receiver android:name=".path.to.ExampleReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_SCREEN_OFF"></action>
</intent-filter>
</receiver>
But when the screen is turned off, the onReceive()
method is not called. What else do I need to do to get this functionality?
Upvotes: 3
Views: 308
Reputation: 1006604
ACTION_SCREEN_OFF
is not sent to receivers registered in the manifest. It is only sent to receivers registered via registerReceiver()
from a running component.
Upvotes: 5