0

I'm trying to develop Appliction that use Xposed Module. In my project I take samples off Apps runing on the device I can choose which Apps. In the Xposed Module I can see if one of my Apps is started by a common list, and I don't successed to start my sampling class because I don't have a context. I tried to do it through FileObserver (the Module writing to a file that the FileObserver observe) from boot service and still on the onEvent func in the FileObserver I don`t have a context too and I don't know how can I start my sample class... Any solution Please?

1 Answers1

0

If you require the context within your Xposed application check this post.

If you require the context from an application you are hooking, then a nice trick is to intercept the launching of new Activities in the application (Activities extend Context). e.g.:

Class<?> instrumentation = XposedHelpers.findClass(
                "android.app.Instrumentation", lpparam.classLoader);

XposedBridge.hookAllMethods(instrumentation, "newActivity", new XC_MethodHook() {

                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {

                    mCurrentActivity = (Activity) param.getResult();

                    Log.v(TAG, "Current Activity : " + mCurrentActivity.getClass().getName());

                    Context ctx = (Context) mCurrentActivity;
                }
});

Good luck!

Community
  • 1
  • 1
4knahs
  • 629
  • 4
  • 14