I'm writing an app that will host widgets. The app has custom view (which probably is the source of issue). I obtain AppWidgetHostView like this
private AppWidgetHostView widget;
...
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
widget = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
widget.setAppWidget(appWidgetId, appWidgetInfo);
mView.addWidget(widget, appWidgetInfo);
mView.addWidget() basically just remembers this AppWidgetHostView instance and then mView draws it directly onto canvas. Visually everything is fine - I can see the actual widget. But the issue is with reacting on UI events. Please advise what needs to be done in the parent view in order to correctly trigger handlers in the widgets like onClick().
Notes:
I used standard widgets which normally react on click events. None worked.
I also created my own test widget with listener (via views.setOnClickPendingIntent(R.id.appwidget_text, pending);) and onClick() is successfully triggered if the widget is added on Homescreen, but doesn't work in my app.
mView correctly detects click event and I tried to call widget.performClick() there, which returns false meaning onClickListener is not registered in the widget. But according to source mAppWidgetHost.createView() would call updateAppWidget which would register its onClick listener..
Please advise where to look at. Thanks