here is my code...can't figure out how should be the return type written
if (lpparam.packageName.equals("com.demo.data")) {
XposedBridge.log("we are in Module!");
findAndHookMethod("com.demo.data.utils.Utils", lpparam.classLoader, "getListFromJsonArrayString", List<String>,new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("we are in method!");
log("call -> " + (String) param.getResult());
}
});
}
List<String> or List<String.class> is not working
The method that i am trying to hook is having return type of
List<string> getListFromJsonArrayString()
First problem:
findAndHookMethod(..., "getListFromJsonArrayString", List<String>, new XC_MethodHook() {
The type list here is for the parameter types. You should not have the return type here (not to mention that this isn't valid Java, you probably meant List.class
). The correct form should be:
findAndHookMethod(..., "getListFromJsonArrayString", new XC_MethodHook() {
This is unambiguous, since you cannot have two Java methods with the same name and parameter type list with different return types.
Second problem:
log("call -> " + (String) param.getResult());
The return type is a List<String>
. You are casting it to a String
, which will obviously not work. Correct form:
log("call -> " + (List<String>) param.getResult());
Note that this will show an unchecked cast warning, but since you know exactly what the generic type is, you can ignore it.