Open nylonW opened 8 years ago
are you want to intergrate the replace text function in you app? if you have xposed, you can hook the setText method in TextView.class and modify the text before setTextMethod。
Can you give me any example? e.g. if i want to change string "text" to "new text" . Xposed of course. Thank you.
a sample code. hope it works for you
XposedHelpers.findAndHookMethod(TextView.class, "setText", CharSequence.class, TextView.BufferType.class, boolean.class, int.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); CharSequence cs = (CharSequence) param.args[0]; if (cs != null && cs instanceof String) { String origin = (String) cs; String result = origin.replace("text", "new text"); param.args[0] = result; } } });
Thank you it works, but how to use it only in specific package? And one more question, how to use it only if my string to replace equals "text". E.g. it works if my string equals "somethingtextsomething" and i don't want it.
@nylonW
use the lpparm.packageName.equals("you packageName ") to check you app ...also the text can be check like that before "replace".
Hi, what is the easiest way to globally replace text which I can use in my app? I know package of app that i want to mod.