Not responce click on widget
I hav开发者_开发问答e different controls on a widget (TextView, ImageView...). On some controls I set setOnClickPendingIntent (for example - tvInfo). It work. On click on TextView I get onReceive my widget.
protected final void addClickListener(String action, int layoutId) {
Log.d(TAG, "addClickListener " + action);
Intent intent = new Intent(WidgetInfo.Context, getMainWidget());
intent.setAction(action);
PendingIntent actionPendingIntent =
PendingIntent.getBroadcast(WidgetInfo.Context, 0, intent, 0);
remoteViews.setOnClickPendingIntent(layoutId, actionPendingIntent);
But if I click on another part of widget (where not set setOnClickPendingIntent) and then again on tvInfo. Nothing happens and onReceive not response. If I repeatedly click on tvIfo then onReceive work. Also, If I double click or even number of times and then again on tvInfo, onReceive response. onReceive not response only if I click on empty part of widget odd number of times.
I solved the problem as follows:
- add setOnClickPendingIntent for top linearLayout of widget;
- set android:soundEffectsEnabled="false" for this linearLayout.
精彩评论