Application-widget-application with user view - onClick does not start in application widgets

I am writing an application that will host widgets. The application has a custom look (which is probably the source of the problem). I get an AppWidgetHostView as follows

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 instance of AppWidgetHostView, and then mView draws it directly onto the canvas. Visually, everything is in order - I see the actual widget. But the problem is responding to user interface events. Please advise what needs to be done in the parent view in order to properly launch the handlers in widgets, for example onClick ().

Notes:

  • I used standard widgets that usually respond to click events. Nothing worked.

  • ( view.setOnClickPendingIntent(R.id.appwidget_text, pending);) onClick() , Homescreen, .

  • mView click, widget.performClick() , false onClickListener . mAppWidgetHost.createView() updateAppWidget, onClick..

, , .

+3
1

ViewGroup, , setLocation() , , . , View View , X Y ( , ).

0

Source: https://habr.com/ru/post/1736526/


All Articles