我怎样才能知道,如果屏幕上的android?屏幕上、android

2023-09-04 08:37:15 作者:旧巷听风

在Android 2.2的(7级)功能 PowerManager.IsScreenOn()返回一个布尔值,为真,如果屏幕打开和虚假如果屏幕关闭。我开发code为Android 1.5(3级)。我如何完成相同的任务在老版本的Andr​​oid?

In Android 2.2 (Level 7) the function PowerManager.IsScreenOn() returns a boolean that is true if the screen is turned on and false if the screen is turned off. I am developing code for Android 1.5 (Level 3). How do I accomplish the same task in older versions of Android?

我不想打开屏幕或关闭在我的code。我只是想知道它是什么。

I do not want to turn the screen on or off in my code. I just want to know what it is.

推荐答案

您可以通过设置的广播接收器的 ACTION_SCREEN_ON ACTION_SCREEN_OFF

You can accomplish this by setting up broadcast receivers for ACTION_SCREEN_ON and ACTION_SCREEN_OFF.