I have the following code:
private static AppWidgetService mInstance = null;
public static void startRefresh() {
AppWidgetProvider.setRefreshingState(mInstance
.getApplicationContext());
AppWidgetManager.refreshHandler(mInstance.getApplicationContext());
}
It sometimes fails in runtime, and sometimes passes.
for the obviuse exception:
cannot call a non-static method from a static context
I'm confused as mInstance is static,
so its instance methods could be called from a static context. no?
then how come if sometimes fails?
So either you remove static from your method header or call these methods using instances of these classes.startRefreshare the problem? Those should be fine. However, yourmInstancevariable might be uninitialized?