Sunzxyong / Tiny

an image compression framework.(一个高保真、高压缩比的图片压缩框架)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android P Q 适配问题

pinguo-sunjianfei opened this issue · comments

private static Application getApplication() {
    Application application = null;
    Method method;
    try {
        method = Class.forName("android.app.AppGlobals").getDeclaredMethod("getInitialApplication");
        method.setAccessible(true);
        application = (Application) method.invoke(null);
    } catch (Exception e) {
        try {
            method = Class.forName("android.app.ActivityThread").getDeclaredMethod("currentApplication");
            method.setAccessible(true);
            application = (Application) method.invoke(null);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    return application;
}

这段代码在android Q P上存在适配问题