开发者

TimerTask and Handler, effect on battery consumption

In my application I update a text box with the latitude/longitude values of the centre of the dis开发者_JS百科played Mapview. I'm doing this by means of a TimerTask which sends a message to to a handler every second.

Is this an inefficient way of doing this, in terms of CPU load/battery consumption?

If so is there a more efficient way of updating the text whenever the centre of the view changes?

This is not connected with GPS, as in one mode of my app I can turn the GPS off and scroll and pan around the map.


Is this an inefficient way of doing this, in terms of CPU load/battery consumption?

I'd use postDelayed() to schedule a Runnable (which reschedules itself via postDelayed() to create your timing loop), so you can avoid the implicit background thread involved in TimerTask. Otherwise, this isn't particularly inefficient.


Timer task with Handler example is here

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜