import android.app.Application;
import java.lang.reflect.InvocationTargetException;
public class AppGlobals {
private static Application sApplication;
public static Application getApplication() {
if (sApplication == null) {
try {
sApplication = (Application) Class.forName("android.app.ActivityThread")
.getMethod("currentApplication")
.invoke(null, (Object[]) null);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
return sApplication;
}
}
AppGlobals
最新推荐文章于 2024-09-11 13:58:07 发布