0

I've a Problem with my widget. The Widget got a Button where i assign a PendingIntent to be fired. When i click the Widgetbutton the first time, nothing happens, when i click it another time, then the Intent gets fired. Then it repeats with don't get fired and then fired.

The Code to assign the PendingIntent is run, each Time the widget updates. (After each button click, including the one that did not fire the Intent. The Action of the Intent is also uniq.

Intent intent= new Intent(context, WidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
intent.setAction(generateUniqAction());
views.setOnClickPendingIntent(R.id.buttonWidget, PendingIntent.getService(context, 0,   intent, 0));

Anyone got an idea on this?

4

1 回答 1

0

在 getService 中使用这个挂起的 Intent 标志

PendingIntent.FLAG_UPDATE_CURRENT

当您单击小部件时,还要检查 logcat 是否存在异常。

于 2011-07-27T10:01:32.413 回答