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

not be able to replace the method of father class #6

Closed
JackCho opened this issue Jul 2, 2015 · 6 comments
Closed

not be able to replace the method of father class #6

JackCho opened this issue Jul 2, 2015 · 6 comments

Comments

@JackCho
Copy link

JackCho commented Jul 2, 2015

No description provided.

@lzwang3d
Copy link
Member

lzwang3d commented Jul 2, 2015

Please point to the father class to hook.

@lzwang3d
Copy link
Member

lzwang3d commented Jul 2, 2015

The way to find hooked method follows java reflection rule. So point to the father class if want to replace the method in it.

@lzwang3d lzwang3d closed this as completed Jul 2, 2015
@JackCho
Copy link
Author

JackCho commented Jul 2, 2015

for example, I want to replace getActivity() method with getMyActivity() in a BaseFragment which is a subclass of Fragment. Opoose, how we can deal with this ?

@lzwang3d
Copy link
Member

lzwang3d commented Jul 2, 2015

Please check if following code for your case:

DexposedBridge.findAndHookMethod(Fragment.class, "getActivity", new XC_MethodHook() {

    @Override protected Object beforeHookedMethod(MethodHookParam param) throws Throwable {
        Fragment obj = (Fragment )param.thisObject;
         if (obj instanceof BaseFragment) {
                  // If instance is BaseFragment, call its getMyActivity 
                  BaseFragment base = (BaseFragment )obj;
                   param.setResult(base.getMyActivity());
         }

    }

});

@JackCho
Copy link
Author

JackCho commented Jul 2, 2015

@lzwang3d thanks for the little trick

@hwjump
Copy link
Contributor

hwjump commented Jul 3, 2015

When you use replace method which need call super method. We provide a new api (invokeSuper() in DexposedBridge) which difference from Xposed. You can use this api in your XC_MethodReplacement method

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

3 participants