I\'m working on a music player-widget (home screen widget).. It only needs to play 1 song, (Preferably with the MediaPlayer class). But I\'m not sure how to implement it. I\
In the onUpdate(...)
method of your AppWidgetProvider
, use something like this to start a service (this example associates the service to a button click event):
Intent intent = new Intent(context, MusicService.class);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider_layout);
views.setOnClickPendingIntent(R.id.button, pendingIntent);
For more info look here
Added <service android:name=".MusicService" android:enabled="true" />
to the manifest!