我有以下代码:
private static AppWidgetService mInstance = null;
public static void startRefresh() {
AppWidgetProvider.setRefreshingState(mInstance
.getApplicationContext());
AppWidgetManager.refreshHandler(mInstance.getApplicationContext());
}
它有时会在运行时失败,有时会通过。
对于明显的例外:
cannot call a non-static method from a static context
我很困惑,因为mInstance
是静态的,
所以它的实例方法可以从静态上下文中调用。不?
那如果有时失败怎么办?