RemoteViewAdapter method returning NULL error?
Whenever i run this method for my StackView...
@Override
public RemoteViews getViewAt(int position) {
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
Bundle extras = new Bundle();
extras.putIn开发者_C百科t(stackWidgetProvider.EXTRA_ITEM, position);
Intent fillnIntent = new Intent();
fillnIntent.putExtras(extras);
rv.setOnClickFillInIntent(R.id.widget_item, fillnIntent);
rv.setImageViewBitmap(R.id.wigdetView, bm);
MyTask myTask = new MyTask();
myTask.execute();
//Do heavy lifting here, Downloading images from a network or website.
return rv ;
}
I get this error in the debug..
08-01 19:48:00.520: ERROR/RemoteViewsAdapter(14319): Error in updateRemoteViews(24): null
08-01 19:48:05.530: ERROR/AppWidgetService(131): Error (unbindRemoteViewsService): Connection not bound
Here is my updateRemoteiews() here...
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for(int i = 0; i < appWidgetIds.length; ++i) {
Intent intent = new Intent(context, StackWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);
rv.setEmptyView(R.id.stack_view, R.id.add);
Intent toastIntent = new Intent(context, stackWidgetProvider.class);
toastIntent.setAction(stackWidgetProvider.TOAST_ACTION);
toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
}
What could the problem be??
I just had this same issue and my problem was that the images that I was loading were too big. After commenting out the code for the images, my problem went away, so now I have to look for a workaround for that (I'm looking for a solution at https://groups.google.com/forum/#!topic/android-developers/bp8ddUGHGhE).
This error is also accompanied by a "FAILED Binder Transaction" in the log cat.
精彩评论