Reputation: 7308
I have a widget that is updated by a service. The service also sets an OnClick event for an ImageButton
that is in the widget layout. The way I do this is by setting a PendingIntent that is supposed to open the service.
However, when I click the refresh button, nothing happens.
public void setRefreshButton(Context context, RemoteViews views) {
Intent widgetUpdateIntent = new Intent(context, UpdateService.class);
PendingIntent pendingRefreshIntent = PendingIntent.getActivity(
context, 0, widgetUpdateIntent, 0);
}
views.setOnClickPendingIntent(R.id.widget_button_refresh,
pendingRefreshIntent);
}
I have a log at the first line of onStart()
of my service, but that doesn't even show up in LogCat. What am I doing wrong?
Upvotes: 0
Views: 103
Reputation: 81349
Your PendingIntent
attempts to starts an Activity
, not a Service
. Try with PendingIntent.getService
.
Upvotes: 2