hookMethod

static boolean hookMethod(Object owner, Member target, Method replacement)

Hook a Java method by providing the target method together with the context object owner and its callback replacement.

Return

If the hook succeed, true, otherwise false.

See also

Parameters

owner

The hooker object to store the context of the hook. Null if replacement is static. The most likely usage is, in Xposed framework, multiple modules can hook the same Java method and the owner can be used to store all the callbacks to allow multiple modules work simultaneously without conflict.

target

The method you want to hook. Must not be null.

replacement

The callback method to the owner object is used to replace the target method. Whenever the target method is invoked, the replacement method will be invoked instead of the original target method. The return type must be the same as the original method and the parameter type must be Hooker.MethodCallback.


static boolean hookMethod(Member target, Method replacement)

Hook a Java method by providing the target method together with its callback replacement.

Return

If the hook succeed, true, otherwise false.

See also

Parameters

target

The method you want to hook. Must not be null.

replacement

The callback method is used to replace the target method. Whenever the target method is invoked, the replacement method will be invoked instead of the original target method.