public abstract class

XC_MethodHook

extends XCallback
java.lang.Object
   ↳ de.robv.android.xposed.callbacks.XCallback
     ↳ de.robv.android.xposed.XC_MethodHook
Known Direct Subclasses

Class Overview

Callback class for method hooks.

Usually, anonymous subclasses of this class are created which override beforeHookedMethod(XC_MethodHook.MethodHookParam) and/or afterHookedMethod(XC_MethodHook.MethodHookParam).

Summary

Nested Classes
class XC_MethodHook.MethodHookParam Wraps information about the method call and allows to influence it. 
class XC_MethodHook.Unhook An object with which the method/constructor can be unhooked. 
[Expand]
Inherited Constants
From class de.robv.android.xposed.callbacks.XCallback
[Expand]
Inherited Fields
From class de.robv.android.xposed.callbacks.XCallback
Public Constructors
XC_MethodHook()
Creates a new callback with default priority.
XC_MethodHook(int priority)
Creates a new callback with a specific priority.
Protected Methods
void afterHookedMethod(XC_MethodHook.MethodHookParam param)
Called after the invocation of the method.
void beforeHookedMethod(XC_MethodHook.MethodHookParam param)
Called before the invocation of the method.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Comparable

Public Constructors

public XC_MethodHook ()

Creates a new callback with default priority.

public XC_MethodHook (int priority)

Creates a new callback with a specific priority.

Note that afterHookedMethod(XC_MethodHook.MethodHookParam) will be called in reversed order, i.e. the callback with the highest priority will be called last. This way, the callback has the final control over the return value. beforeHookedMethod(XC_MethodHook.MethodHookParam) is called as usual, i.e. highest priority first.

Parameters
priority See XCallback.priority.

Protected Methods

protected void afterHookedMethod (XC_MethodHook.MethodHookParam param)

Called after the invocation of the method.

You can use XC_MethodHook.MethodHookParam.setResult(Object) and XC_MethodHook.MethodHookParam.setThrowable(Throwable) to modify the return value of the original method.

Note that implementations shouldn't call super(param), it's not necessary.

Parameters
param Information about the method call.
Throws
Throwable Everything the callback throws is caught and logged.

protected void beforeHookedMethod (XC_MethodHook.MethodHookParam param)

Called before the invocation of the method.

You can use XC_MethodHook.MethodHookParam.setResult(Object) and XC_MethodHook.MethodHookParam.setThrowable(Throwable) to prevent the original method from being called.

Note that implementations shouldn't call super(param), it's not necessary.

Parameters
param Information about the method call.
Throws
Throwable Everything the callback throws is caught and logged.