CPU Spy Gets an Android Lollipop Makeover

At some point in the distant past, you probably heard of CPU Spy for Android by XDARetired … more

Amazon Fire TV Stick vs Chromecast – XDA TV

There is no doubt that Amazon is a huge player in many markets, and they want to be a huge … more

Fight the Heat and Conserve Battery with EaseUS Coolphone

Memory hungry Android applications are often responsible for making our device … more

Battery Charged in 30 Seconds? Maybe in 2016

Phones and tablets are getting more and more power hungry with each passing generation. Their … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Different parameters for specific OS version

OP pyler

3rd August 2014, 04:56 PM   |  #1  
OP Senior Member
Thanks Meter: 575
 
474 posts
Join Date:Joined: Jan 2013
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, 02:24 AM   |  #2  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 7,220
 
5,870 posts
Join Date:Joined: Aug 2012
Donate to Me
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 02:26 AM.
The Following User Says Thank You to GermainZ For This Useful Post: [ View ]
4th August 2014, 03:28 PM   |  #3  
OP Senior Member
Thanks Meter: 575
 
474 posts
Join Date:Joined: Jan 2013
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