public static Application getApplicationContext() {
        if (application != null) {
            return application;
        }
        try {
            Application application = (Application) Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null, (Object[]) null);
            return application;
        } catch (Exception e) {
        }
        try {
            Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
            Object activityThread = activityThreadClass.getDeclaredMethod("currentActivityThread").invoke(null);
            Method getApplicationMethod = activityThreadClass.getDeclaredMethod("getApplication");
            Application application = (Application) getApplicationMethod.invoke(activityThread);
            return application;
        } catch (Exception e) {
        }
        try {
            Application application = (Application) Class.forName("android.app.AppGlobals").getMethod("getInitialApplication").invoke(null, (Object[]) null);
            return application;
        } catch (Exception e) {
        }
        return null;
    }
@author: Kongzue
@github: https://github.com/kongzue/
@homepage: http://kongzue.com/
@mail: myzcxhh@live.cn
@createTime: 2020/9/22 11:31
DialogX/src/main/java/com/kongzue/dialogx/impl/ActivityLifecycleImpl.java