Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect whether screen is on or off if API level is 4?

Tags:

android

I am wondering to know how to detect screen dim or brightness on Android 1.6.

I've found a solution on API Level 7. It is easy to develop :

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); boolean isScreenOn = pm.isScreenOn(); 

But I need a solution for Android 1.x.

Can you suggest me ?

Thanks.

like image 390
Ferdinand Avatar asked May 11 '11 07:05

Ferdinand


1 Answers

For screen on-off state, you can try with ACTION_SCREEN_ON and ACTION_SCREEN_OFF Intents, as shown in this blog post: http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/

like image 53
Nacho L. Avatar answered Oct 06 '22 01:10

Nacho L.