0
我額外添加到意圖,像這樣:如何從RemoteViewsService中的意圖訪問額外內容?
Intent adapterIntent = new Intent(context, MyRemoteViewService.class);
adapterIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, currentWidgetID);
adapterIntent.setData(Uri.parse(adapterIntent.toUri(Intent.URI_INTENT_SCHEME)));
views.setRemoteAdapter(R.someLV, adapterIntent);
在MyRemoteViewService.java,我試圖讓像小部件ID,以便:
@Override public RemoteViewsFactory onGetViewFactory(Intent intent) {
String currWidgetID = intent.getData().getPath();
我用的getData()而不是getExtras()因爲它總是返回null。