嗨我试图通过PendingIntent发送额外的数据。通过PendingIntent发送EXTRA数据问题
这是我的代码
//**1**
Intent intent = new Intent(context, UpdateService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
appWidgetId);
intent.putExtra(BaseConfigurationActivity.EXTRA_WIDGET_MODE,
2);
// put appWidgetId here or intent will replace an intent of
another widget
PendingIntent pendingIntent =
PendingIntent.getService(context, appWidgetId, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.gridview_button,
pendingIntent);
//**2**
intent = new Intent(context, UpdateService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
appWidgetId);
intent.putExtra(BaseConfigurationActivity.EXTRA_WIDGET_MODE,
1);
// put appWidgetId here or intent will replace an intent of
another widget
pendingIntent = PendingIntent.getService(context, appWidgetId,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.listview_button,
pendingIntent);
在我的代码将其分配的PendingIntent两个按钮gridview_button与EXTRA_WIDGET_MODE 2 和listview_button与EXTRA_WIDGET_MODE 1
当我点击gridview_button并调用UpdateService类 我也得到EXTRA_WIDGET_MODE值是“1”
我做错了什么?
您需要给我们一些更多的细节。什么是你的问题?你有什么错误吗?如果是这样,你可以发布stacktrace吗? – 2011-01-14 08:16:29
对不清楚的问题感到抱歉。在代码“gridview_button”的PendingIntent中,EXTRA数据“EXTRA_WIDGET_MODE”=“2”当我运行我的代码时,我也得到了EXTRA_WIDGET_MODE的值“1” – SnowBEE 2011-01-14 10:03:48
请写下你自己的答案,然后接受它作为答案。 – mad 2011-02-09 11:48:44