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

链接地址: http://www.djcxy.com/p/50612.html

上一篇: Android:BatteryLevel小部件未更新

下一篇: 服务不会在onReceive AppWidgetProvider中启动