android.intent.action.SCREEN_ON doesn't work as a receiver intent filter
Posted
by Jim Blackler
on Stack Overflow
See other posts from Stack Overflow
or by Jim Blackler
Published on 2010-04-04T17:27:04Z
Indexed on
2010/04/04
17:33 UTC
Read the original article
Hit count: 1080
android
|broadcastreceiver
I'm trying to get a BroadcastReceiver invoked when the screen is turned on. In my AndroidManifest.xml I have specified :
<receiver android:name="IntentReceiver">
<intent-filter>
<action android:name="android.intent.action.SCREEN_ON"></action>
</intent-filter>
</receiver>
However it seems the receiver is never invoked (breakpoints don't fire, log statements ignored). I've swapped out SCREEN_ON for BOOT_COMPLETED for a test, and this does get invoked.
This is in a 1.6 (SDK level 4) project.
A Google Code Search revealed this, I downloaded the project and synced it, converted it to work with latest tools, but it too is not able to intercept that event.
Is this perhaps no longer supported?
Previously I have been able to intercept this event successfully with a call to Context.registerReceiver() like so
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// ...
}
}, new IntentFilter(Intent.ACTION_SCREEN_ON));
However this was performed by a long-living Service. Following sage advice from CommonsWare I have elected to try to remove the long-living Service and use different techniques. But I still need to detect the screen off and on events.
© Stack Overflow or respective owner