How to update widget every minute

后端 未结 2 659
挽巷
挽巷 2020-12-17 04:36

can anyone tell me the best way to update widget every minute.

Now i\'m using thread inside the AppWidget, but sometimes i get error FAILED BINDER TRANSACTION !!! A

2条回答
  •  心在旅途
    2020-12-17 05:13

    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.

    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).

    There are numerous examples around the internet that should explain the ins and outs of using the AlarmManager to raise your AppWidget Update Intents.

提交回复
热议问题