Search code examples
androidandroid-widgetbackground-musicandroid-music-player

No idea on how to update widget from service


I've been trying to make a widget to my music app. The app has a service that handles the mediaplayer so that i can "minimize" the app and yet continue listening to music. I know that i need to update the widget from the service, but all the examples i've found, wants me to start a new service on each update, and that's not what i want.

Any help is appreciated!

Thanks in advance


Solution

  • You can do it without the service too. The service is recommended because if your updation takes too much time, android may close it and give Application Not Responding (ANR) error message. These are the cases like when you send a web-service request. Otherwise, you can use your custom AppWidgetProvider to update your widget (without making a service), using RemoteViews(the same way you do in the service). For more on how to do that refer this