开发者

In android program, how to know whether the desktop is visible?Is there a filter action somebow like Intent.ACTION_DESKTOP_VISIBLE and INVISIBLE?

Imagine y开发者_StackOverflow中文版ou are working on a widget with a background service , and it eat battery fast, So you don't want it to run all the time: when the sceen off, stop it. When the screen on enable it. But that is not enough, when there is a foreground activity running( you cannot see the widget, so you don't need it.stop it ). And renable it when we back to the desktop.

Is there a solution? Help!


There aren't any Intents broadcast AFAIK that tell you when or when not the desktop is not visible. Widgets are only supposed to lightweight windows onto your application - the solution is to reduce the battery usage of your widget.

If you use AlarmManager together with a non _WAKEUP alarm type to update your widget and specify an update time of 0 in your XML, then your widget will only be updated while the phone is awake.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜