0

在我的应用程序中,我想从 TextEdit 中挂钩 SetValue(String) 我尝试了这样的代码,但没有运气。

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]);

                }

            });
        }
    }
}

有人知道上面的钩子代码有什么问题吗?

4

1 回答 1

1

Android API[0] 中没有以下定义的函数。

android.widget.EditText.setValue(String)

所以,基本上你挂错了功能。可能是你想上钩android.widget.EditText.setText(CharSequence, TextView.BufferType)

此外,您可以检查 Xposed 日志以了解代码中的挂钩错误。NoSuchMethodException当您尝试挂钩错误的功能时会抛出。

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

于 2016-12-30T19:33:52.327 回答