Monday, June 6, 2011

[android-developers] Handling Screen OFF and Screen ON Intents

I'm trying to get a BroadcastReceiver invoked when the screen is
turned on or off.

In my AndroidManifest.xml I have specified :

<receiver android:name=".ScreenReceiver">
<intent-filter>
<action
android:name="android.intent.action.SCREEN_ON"></action>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>

<receiver android:name=".ScreenReceiver1">
<intent-filter>
<action android:name="android.intent.action.SCREEN_OFF"></
action>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>

In my ScreenReceiver.java I have specified :

public void onReceive(Context context, Intent intent) {
try {
Toast.makeText(context, "Device Haythem SCREEN TURNED
ON", Toast.LENGTH_LONG).show();
} catch (Exception e) {
}

}

In my ScreenReceiver1.java I have specified :

public void onReceive(Context context, Intent intent) {
try {
Toast.makeText(context, "Device Haythem SCREEN TURNED
OFF", Toast.LENGTH_LONG).show();
} catch (Exception e) {
}

}

it don't work. My device didn't detect anythink.

Please what's the problem???

Thanks

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate