0

I'm trying to build a basic music player but right now I'm stuck at making widget for it. Can someone tell me how do I connect widget to the background service? I'm using MediaBrowser,MediaController on the client side and MediaBrowserService,MediaSession in the background service. So, to create a instance of MediaController, I require activity which isn't available in widget class if I'm not wrong and if I try to bind widget class to service using bindService and returning an instance of the background service class method I'm getting error (which is resolved once I comment the onBind method in the service)

How do I proceed?

Pang
  • 9,564
  • 146
  • 81
  • 122

1 Answers1

0

AppWidgetProvider is a BroadcastReceiver on steroids. But you can't bind to service from BroadcastReceivers (That was done because BroadcastReceiver is lightweight component that have shot livetime (10 seconds)). In your case best way to communicate with music service is use broadcasts (pending intents).

HeyAlex
  • 1,666
  • 1
  • 13
  • 31