开发者

PendingIntent only fired every second time

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?


Use this pending Intent flag in getService

PendingIntent.FLAG_UPDATE_CURRENT

Also check logcat for exceptions when you click on widget.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜