简体   繁体   中英

How to hook SetValue(String) in Xposed module

In my app I want to hook SetValue(String) from TextEdit I tried code like this but no luck.

public class XposedClass implements IXposedHookLoadPackage {

    public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {

        String classToHook = "android.widget.EditText";
        String functionToHook = "setValue";

        if(lpparam.packageName.equals("my.com.app")) {

           XposedBridge.log("Loaded app: " + lpparam.packageName);

           findAndHookMethod(classToHook, lpparam.classLoader, functionToHook, String.class,
                   new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

                    XposedBridge.log("hooking: " + param.args[0]);

                }

            });
        }
    }
}

Anyone knows whats wrong with hook code above ?

There's no function with following definition in the Android API[0].

android.widget.EditText.setValue(String)

So, basically you are hooking wrong function. May be you wanted to hook android.widget.EditText.setText(CharSequence, TextView.BufferType)

Moreover you can check the Xposed logs to know hooking errors in your code. NoSuchMethodException would be thrown when you will try to hook wrong function.

[0] https://developer.android.com/reference/android/widget/EditText.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM