开发者

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);


Try overriding onUpdate instead in the AppWidgetProvider instead of onReceive.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜