如何更新Android小工具每一秒......画有秒针的时钟? [英] How to update an Android widget every second ... to draw a clock with a seconds hand?

查看:455
本文介绍了如何更新Android小工具每一秒......画有秒针的时钟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从各种来源读太多的方式来更新正在使用ImageView的画布小部件,并绘制方法来显示与秒针的时钟。

I have been reading much from various sources on ways to update a widget that is using ImageView Canvas and Draw method to display a clock with a seconds hand.

必须每秒更新一次。什么是最有效的方式做到这一点?使用服务,报警管理,处理程序?

It must be updated every second. What is the most efficient way to do this? Use a Service, the Alarm Manager, Handlers?

这是可以做到,比如,Android应用弧时钟小工具

It can be done, e.g., the Android app "Arc Clock Widget".

与任何人任何想法?

谢谢,
汤姆

推荐答案

有此页:)的的教程上作出模拟时钟部件的Andr​​oid

我已经使用了AlarmManager这个做我自己,我没有发现任何显著电池消耗的AlarmManager不会唤醒手机更新widget时手机是睡着了。不管怎么说,没有人会看到widget时手机是睡着了。此外,请参阅在Android开发者指南的这一部分这一点。 使用AlarmManager频繁更新

I have used the AlarmManager to do this myself and I did not notice any significant battery drain as the AlarmManager does not wake the phone to update the widget when the phone is asleep. Anyways, no one will be seeing the widget when the phone is asleep. Also, see this note on this section of the Android Developer Guide. Using AlarmManager to update frequently

这篇关于如何更新Android小工具每一秒......画有秒针的时钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆