嘿,我有应用程序小部件,我想通过点击小部件发送一些数据到附加到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