Android widget update after x time

前端 未结 2 804
悲哀的现实
悲哀的现实 2021-01-15 04:12

I just started to learn Android, I\'m trying to write a widget which is updating the counter in every seconds, but somewhere it\'s missing something.I\'m getting 1 on the sc

相关标签:
2条回答
  • 2021-01-15 04:39

    after

    appWidgetManager.updateAppWidget(appWidgetId, views);
    

    add this

    super.onUpdate(context, appWidgetManager, appWidgetId);
    

    i believe this will solve your problem

    0 讨论(0)
  • 2021-01-15 04:45

    Here is a great tutorial series for creating widgets in Android and updating them at intervals. It starts here: http://android-er.blogspot.com/2010/10/simple-home-screen-app-widget-with.html

    And ends here with a recurring timer/alarm: http://android-er.blogspot.com/2010/10/app-widget-using-alarm-manager.html

    Basically you need to setup some things in the manifest to listen for a broadcasted intent which updates the widget. It also shows how to create a config activity for the widget.

    To create alarms or recurring events you can also use the AlarmManager class.

    0 讨论(0)
提交回复
热议问题