xposed 获取上下文context

获得当前的context

Context context = (Context) AndroidAppHelper.currentApplication();

获取第三方的

XposedHelpers.findAndHookMethod("android.app.Instrumentation", lpparam.classLoader, "callApplicationOnCreate", Application.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                if (param.args[0] instanceof Application) {

                    try {
                        xcontext = ((Application) param.args[0]).getApplicationContext();
                    } catch (Exception ee) {
                        XposedBridge.log("" + ee.toString());
                    }
               }
          }
});
点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注