xposed自定义参数
Posted codedevotee
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xposed自定义参数相关的知识,希望对你有一定的参考价值。
java反射机制允许在不显式调用类及类方法的前提下,实现创建类对象、调用类方法等一系列操作。 目标函数为TestArray,其参数为我们自定义的Person类的数组。 public class test { public static void main(String[] args){ Person person1 = new Person("aa",12,"male"); Person person2 = new Person("ab",13,"female"); Person person3 = new Person("ac",14,"male"); Person[] person = new Person[]{person1,person2,person3}; System.out.print(TestArray(Person[] person)); } public String TestArray(Person[] person){ String result = ""; for (int i =0;i<person.length;i++){ result += "name = "+person[i].getName()+",age = " +person[i].getAge()+",gender = "+person[i].getGender()+" "; } return result; }; } Person 类为: public class Person { private String name; private int age; private String gender; public Person(String name,int age,String gender){ this.name = name; this.age = age; this.gender = gender; }; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } } 使用Xposed去hook方法TestArray(Person[] person)时,hook方法为: Class<?> personClass = findClass("com.zq.inputmethodtest.Person",lpparam.classLoader); findAndHookMethod("com.zq.inputmethodtest.MainActivity", lpparam.classLoader, "TestArray",java.lang.reflect.Array.newInstance(personClass, 2).getClass(), new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { param.setResult("person数组被修改"); Log.d("InputTest-->after ",""+ param.getResult()); } }); 利用反射方法获取Person类的class对象
以上是关于xposed自定义参数的主要内容,如果未能解决你的问题,请参考以下文章