3

I am developing a Widget for my app and I have a problem :

the onGetViewFactory method of my android.widget.RemoteViewsService class are not called !

My code :

IntentService

  this.views = new RemoteViews(this.ctx.getPackageName(), i);
  Intent localIntent = new Intent(this.ctx, MyWidgetService.class);
  localIntent.putExtra("WidgetId", param);
  localIntent.setData(Uri.parse(localIntent.toUri(Intent.URI_INTENT_SCHEME)));

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) 
  this.views.setRemoteAdapter(R.id.weather_list, localIntent);
  else
  this.views.setRemoteAdapter(param, R.id.weather_list, localIntent);

  ComponentName localComponentName = new ComponentName(this.ctx, MyWidgetProvider.class);
  AppWidgetManager localAppWidgetManager = AppWidgetManager.getInstance(this.ctx);
  localAppWidgetManager.notifyAppWidgetViewDataChanged(param, R.id.weather_list);
  localAppWidgetManager.updateAppWidget(param, this.views);

MyWidgetService

My class extends RemoteViewsService and have this code

@Override
    public RemoteViewsFactory onGetViewFactory(Intent intent) {
        // TODO Auto-generated method stub
        System.out.println("test");
        return null;
    }

MyWidgetProvider My class extends AppWidgetProvider

Can anybody help me? What's wrong in my code?

Thank you :-)

Edit : Yes but when I put a breakpoint or Log, It is the same.

4

1 回答 1

4

您是否已在 中声明您的服务AndroidManifest.xml

<service
     android:name="com.mypackage.MyWidgetService"
     android:exported="false"
     android:permission="android.permission.BIND_REMOTEVIEWS" >
</service>
于 2013-10-14T10:56:36.597 回答