user2402911
user2402911

Reputation: 43

onGetViewFactory not called

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.

Upvotes: 3

Views: 2074

Answers (1)

Viacheslav
Viacheslav

Reputation: 5593

Have you declared your service in AndroidManifest.xml?

<service
     android:name="com.mypackage.MyWidgetService"
     android:exported="false"
     android:permission="android.permission.BIND_REMOTEVIEWS" >
</service>

Upvotes: 5

Related Questions