0

I need to catch longClick-Events from AppWidgetHostViews like discussed here:

appwidgethostview-cant-handle-onclick-onlongclick-properly

So i need write a class that extends AppWidgetHostView for this, but when it comes to:

MyAppWidgetHostView hostView = (MyAppWidgetHostView) m_AppWidgetHost.createView(this, appWidgetId, appWidgetInfo);

....App crashes. Cannot typecast from AppWidgetHostView to MyAppWidgetHostView. What am i doing wrong/misssing?

Community
  • 1
  • 1
treesoft
  • 295
  • 2
  • 14
  • Google downcasting and why this case is not available in Java. – MLProgrammer-CiM Aug 07 '14 at 14:23
  • ok i understand it, but how can i do this (catching the long-click on AppWidgets) then? It worked at least for one person in the linked post.... – treesoft Aug 07 '14 at 14:53
  • You can't, it is a conceptual error. You need to rethink your architecture and maybe make AppWidgetHostView a field/child of your new view instead. Look at his code closely, he never casts. – MLProgrammer-CiM Aug 07 '14 at 14:55
  • thx a lot MLProgrammer-CiM , it works now and really learned from this. – treesoft Aug 07 '14 at 20:26

0 Answers0