Post Reply Subscribe to Thread Email Thread

Replace method. Need help. PLease

28th August 2014, 04:31 PM |#1  
S0bes's Avatar
OP Senior Member
Flag Tomsk
Thanks Meter: 527
513 posts
Join Date:Joined: Jan 2012
Donate to Me
Hi everyone. I ask for help. I literally beg for it..
You can see it here
I only want to replace method . Any of them.
For example I want this method returns FALSE every time it's called.
   public boolean isValidDialpadAlphabeticChar(char ch) {
       return (ch >= 'a' && ch <= 'z');
Here is my code
public class Fm implements IXposedHookLoadPackage {      
    public void handleLoadPackage(final LoadPackageParam loadpkg) throws Throwable { 
        if (loadpkg.packageName.equals("")) { 
            ClassLoader classLoader = loadpkg.classLoader; 
            XC_MethodReplacement methodreplacer = new XC_MethodReplacement() {  
                protected Object replaceHookedMethod( 
                        XC_MethodHook.MethodHookParam paramAnonymousMethodHookParam)
                        throws Throwable {
                	 XposedBridge.log("ALLLLL RIGHTTTT . NOW We ARE IN. AND MADE IT FALSe"); 
                    return false;  
            XposedHelpers.findAndHookMethod("", loadpkg.classLoader,
                    "isValidDialpadAlphabeticChar", Character.class, methodreplacer);
But this doesn't work
Here what I see in xposed log file:
java.lang.NoSuchMethodError: idDialpadAlphabeticChar(java.lang.Character)#exact
at ct(
at thod(
at thod(
at com.s0bes.fmspeaker.Fm.handleLoadPackage( 0)

BUUUT. If I will try to replace other method. For example
matchesCombination in (
Here the part of code which was changed:
XposedHelpers.findAndHookMethod("", loadpkg.classLoader,
                    "matchesCombination", String.class, String.class, ArrayList.class, methodreplacer);
Now everything work...
So, it works with one thing and doesnt work with method I need
30th August 2014, 02:38 PM |#2  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 8,033
6,142 posts
Join Date:Joined: Aug 2012
If you want to replace a method to return a consatnt, you can use the XC_MethodReplacement.returnConstant(…) shortcut. For example:
Select Code
XposedHelpers.findAndHookMethod("", loadpkg.classLoader,
                    "matchesCombination", String.class, String.class, ArrayList.class, XC_MethodReplacement.returnConstant(false));
As for your problem, you're trying to hook isValidDialpadAlphabeticChar(Character.class), but you should be hooking isValidDialpadAlphabeticChar(char.class). Just replace "Character.class" by "char.class" in your findAndHookMethod call.
The Following User Says Thank You to GermainZ For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes