Service not being launched in onReceive AppWidgetProvider
Here is my onReceive inside of my AppWidgetProvider for my widget.
@Override
public void onReceive(Context context, Intent intent){
AppWidgetManager.getInstance(context);
super.onReceive(context, intent);
Log.e("stackWidgetProvider", "Inside onReceive!");
intent = new Intent(context, widget_release_service.class);
context.startService(intent);
}
The only problem is that the service is never launched.
Here is it declared in the manifest..
<service android:name=".widget_release_service"
android:enabled="true"
/>
Why isnt the service being launched?
EDIT:
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){
super.onUpdate(context, appWidgetManager, appWidgetIds);
Log.e("StackWidgetProvider", "Inside onUpdate");
Intent intent = new Intent(context, widget_release_service.class);
context.startService(intent);
尝试覆盖onUpdate
而不是在AppWidgetProvider而不是onReceive
。