Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android P Q 适配问题 #74

Open
pinguo-sunjianfei opened this issue May 6, 2019 · 1 comment
Open

Android P Q 适配问题 #74

pinguo-sunjianfei opened this issue May 6, 2019 · 1 comment

Comments

@pinguo-sunjianfei
Copy link

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上存在适配问题

@Sunzxyong
Copy link
Owner

@pinguo-sunjianfei OK~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants