When updating my app widget I need to check the provider class name.
appWidgetManager.getAppWidgetInfo(widgetId).provider.className
But sometimes I face the exception Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'android.content.ComponentName android.appwidget.AppWidgetProviderInfo.provider' on a null object reference
And I don't know why. Documentation of getAppWidgetInfo
says:
If the appWidgetId has not been bound to a provider yet, or you don't have access to that appWidgetId, null is returned.
I guess my case is "the appWidgetId has not been bound to a provider", but how to catch the moment when a widget is bound already? Or maybe the problem is something else?