问题描述
谁能告诉我更新部件每分钟的最佳方式。
can anyone tell me the best way to update widget every minute.
现在我使用的线程AppWidget内,但有时我得到错误而失败粘结剂的交易!这个错误后,我总是有很多错误的一样,所有的时间,我不能再改变我的插件的看法。
Now i'm using thread inside the AppWidget, but sometimes i get error FAILED BINDER TRANSACTION !!! After that error, i always got a lot of error like that all the time and i can't change the view in my widget again.
感谢
推荐答案
而不是使用在AppWidget一个线程,您将得到更好的使用AlarmManager安排重复AppWidget更新意图,你的code将处理服务适当的。
Rather than using a thread in the AppWidget, you would be better served by using the AlarmManager to schedule a repeating AppWidget Update Intent which your code would handle appropriately.
这种方法的好处是配置的更新速度,并且还可以处理装置睡的情况下(而不是意识到了运行code,甚至睡觉被阻止,因为你的线程是忙的可能性)。
The benefits of this approach is the possibility to configure the update rate, and also handle the case of the device sleeping (and not waking up to run your code, or even being blocked from sleeping because your thread is busy).
有许多examples应该说明使用AlarmManager来提高你的AppWidget更新意图的来龙去脉在互联网附近。
There are numerous examples around the internet that should explain the ins and outs of using the AlarmManager to raise your AppWidget Update Intents.
这篇关于如何更新插件每分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!