Following the example here i created my widget with ease.
I then added a button to my widget, this button should start a service so I added the following code to my WidgetProvider
@Override
public void onEnabled(Context context) {
Log.e("ERROR", "REMOVE ME"); // TODO remove. This is for eclipse logcat recognition
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
Intent intent = new Intent(context, RepairService.class);
PendingIntent pi = PendingIntent.getService(context, 0, intent, 0);
views.setOnClickPendingIntent(R.id.widget_boost, pi);
}
The code certainly gets called, but service doesn’t get started. I’m sure I have probably missed something with implementation of a service PendingIntent, but I can’t see what. Anyone else know?
Well I have managed to fix it
I am not entirely sure what was wrong with doing it in onEnable. Maybe someone can shed some light as to why.