我正在尝试将一些可分隔的数组传递给RemoteViewsFactory
到RemoteViewsService
。在我的自定义AppWidgetProvider
内,我有如下情况:
Intent appWidgetIntent = new Intent(context, ReportRemoteViewsService.class);
appWidgetIntent.putParcelableArrayListExtra("list", list);
appWidgetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.appwidget_report_layout);
rv.setRemoteAdapter(R.id.appwidget_report_listview, appWidgetIntent);
//dumpIntent(appWidgetIntent);
appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
list
是ArrayList<CustomObject>
其中CustomObject implements Parcelable
(writeToParcel
和静态CREATOR
)。我正在打印额外内容,并且列表和ID都有,但是当我在Intent
内打印RemoteViewsFactory
时,只有appWidgetId
...
public class ReportRemoteViewsService extends RemoteViewsService {
@Override
public RemoteViewsFactory onGetViewFactory(Intent intent{
//dumpIntent(intent);
return new ReportRemoteViewsFactory(this.getApplicationContext(), intent);
}
}
当我尝试传递单个parcelable(不是数组)时的情况相同。为什么?!