Devs Beware – Automatic Backup Privacy Risks

One new feature of “Android M” (speculation on potential names welcomed … more

Android M to Bring New App Drawer

It has now been seen that Android M will receive a new app drawer as part of the stock … more

Which IO Announcement Are You Most Excited About?

The keynote we had all been waiting for has just ended and it’s time to enjoy … more

Google Launches Google Photos At I/O 2015 Keynote

While rumors have been floating around for a while, the Google I/O 2015 has made … more
pyler's Avatar

Different parameters for specific OS version

Thanks Meter: 907
 
By pyler, Senior Member on 3rd August 2014, 03:56 PM
Post Reply Subscribe to Thread Email Thread
3rd August 2014, 03:56 PM |#1  
OP Senior Member
Thanks Meter: 907
 
More
I have code like this:
XposedHelpers.findAndHookMethod(packageManagerServ ice, null,
"anything", String.class, Integer.class, Integer.class, new XC_MethodHook() {

How can I change bolded code for specific Android Version?

For example:
if Android version is lower than JB MR2 then params = String.class, Integer.class, Integer.class, Integer.class else params = String.class, Integer.class, Integer.class

?
 
 
4th August 2014, 01:24 AM |#2  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 8,228
 
More
Either pass the array of classes to e.g. findAndHookMethod, or define the hook and use different findAndHookMethod calls with the arguments you want.

Code:
Object[] argumentClasses;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
    argumentClasses = new Object[]{argumentClass1, argumentClass2};
else
    argumentClasses = new Object[]{argumentClass1};
findAndHookMethod(class, method, argumentClasses, hook);
Or:
Code:
XC_MethodHook hook = new XC_MethodHook() {
    @Override
        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
            // Hook
        }
};

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
    findAndHookMethod(class, method, argumentClass1, argumentClass2, hook);
else
    findAndHookMethod(class, method, argumentClass1, hook);
Last edited by GermainZ; 4th August 2014 at 01:26 AM.
The Following User Says Thank You to GermainZ For This Useful Post: [ View ]
4th August 2014, 02:28 PM |#3  
OP Senior Member
Thanks Meter: 907
 
More
Great! Thank you!
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes