1

我的应用程序使用HandlerandsendEmptyMessageDelayed来获取产生调试输出的定时消息。当我按下 Galaxy Tab 的电源时,屏幕关闭,但调试消息不断出现。

我宁愿CPU进入睡眠状态。发生这种情况是因为它已插入 PC 吗?还是我的应用程序做错了什么使设备保持清醒?

4

1 回答 1

2

Turning the screen off doesn't put the phone into "sleep" mode, similarly to turning your computer monitor off won't put your computer into "sleep" mode. Mobile devices are designed to have quick responsiveness when you need them, thus never go to sleep unless explicitly told to (If such a function even exists).

In the context of an application, processing on the main (UI) thread decreases dramatically since UI elements are no longer being drawn to the screen. However, background processes still function as you would expect them to regardless of the screen state.

If you want your app to stop some processing when not in the foreground, check for calls to onPause() in your Activities, and do what you wish. onPause() will be called when changing Activities, turning the screen off, or moving the app into the background.

于 2012-06-11T20:54:34.067 回答