You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BGABaseAdapterUtil 获取 Application时不要调用隐藏 API;
public class BGABaseAdapterUtil {
private static Application sApp;
static {
Application app = null;
try {
app = (Application) Class.forName("android.app.AppGlobals").getMethod("getInitialApplication").invoke(null);
if (app == null)
throw new IllegalStateException("Static initialization of Applications must be on main thread.");
} catch (final Exception e) {
Log.e(BGABaseAdapterUtil.class.getSimpleName(), "Failed to get current application from AppGlobals." + e.getMessage());
try {
app = (Application) Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null);
} catch (final Exception ex) {
Log.e(BGABaseAdapterUtil.class.getSimpleName(), "Failed to get current application from ActivityThread." + e.getMessage());
}
} finally {
sApp = app;
}
}
}
建议让调用者传过来吧。这样很容易出问题。
The text was updated successfully, but these errors were encountered:
BGABaseAdapterUtil 获取 Application时不要调用隐藏 API;
public class BGABaseAdapterUtil {
private static Application sApp;
}
建议让调用者传过来吧。这样很容易出问题。
The text was updated successfully, but these errors were encountered: