嘿,我有應用程序小部件,我想通過點擊小部件發送一些數據到附加到PendingIntent的意圖。 這裏是我的代碼應用程序小部件捆綁?
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
Intent intent = new Intent(context, UpComingBDays.class);
if(bdaysAmount != 0){
Bundle bundle = new Bundle();
bundle.putIntegerArrayList("WIDGETIDS", tempAllIDS);
intent.putExtras(bundle);
System.out.println("bund insertedddddddddddddd.....................");
}
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, 0);
RemoteViews remoteView = new RemoteViews(context.getPackageName(),
R.layout.widget_layout);
remoteView.setTextViewText(R.id.widget_text, finalText4TextView);
remoteView.setOnClickPendingIntent(R.id.WidgetImageButton, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, remoteView);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
我認識總是「外灘insertedddddddddd ......」被印在目錄下載,但目的的包是空。
有什麼不對?我怎樣才能發送數據通過點擊小部件。 plz不要提供使用服務,因爲我的代碼沒有任何東西。 非常感謝。
謝謝回答CW。我沒有使用你的建議,因爲我已經改變了解決這個問題的方法。最初我正在做一些計算和服務調用的widget類,但我改變了這一點,把所有的邏輯連接意圖。 – 2011-01-12 01:11:42