0
每當我跑我的StackView這種方法...RemoteViewAdapter方法返回NULL錯誤?
@Override
public RemoteViews getViewAt(int position) {
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
Bundle extras = new Bundle();
extras.putInt(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 ;
}
我在調試得到這個錯誤..
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
這裏是我的updateRemoteiews()在這裏......
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);
}
問題是什麼?