Allow the widget to start the music service

This commit is contained in:
Christopher Eby 2010-02-26 23:55:03 -06:00
parent 1a259e714a
commit a456aa8c04
3 changed files with 9 additions and 4 deletions

View File

@ -2,7 +2,9 @@
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/stopped_text"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:gravity="center"
android:text="Service stopped." />
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:background="#000"
android:textColor="#fff"
android:text="@string/widget_start_service" />

View File

@ -11,6 +11,7 @@
<string name="stop_service">Stop Service</string>
<string name="connect_to_service">Connect to Service</string>
<string name="paused">(Paused)</string>
<string name="widget_start_service">Click to start the music service.</string>
<string name="headset_only_title">Headset only</string>
<string name="headset_only_summary_on">Audio only plays when a headset is plugged in</string>

View File

@ -12,6 +12,7 @@ public class OneCellWidget extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager manager, int[] ids)
{
reset(context);
context.sendBroadcast(new Intent(PlaybackService.APPWIDGET_SMALL_UPDATE));
}
@ -36,6 +37,7 @@ public class OneCellWidget extends AppWidgetProvider {
public static void reset(Context context)
{
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.default_widget);
views.setOnClickPendingIntent(R.id.stopped_text, PendingIntent.getService(context, 0, new Intent(context, PlaybackService.class), 0));
sendUpdate(context, views);
}
}