public final class

XposedBridge

extends Object
java.lang.Object
   ↳ de.robv.android.xposed.XposedBridge

Class Overview

This class contains most of Xposed's central logic, such as initialization and callbacks used by the native side. It also includes methods to add new hooks.

Summary

Fields
public static final ClassLoader BOOTCLASSLOADER The system class loader which can be used to locate Android framework classes.
public static int XPOSED_BRIDGE_VERSION This field was deprecated in API level 65. Use getXposedVersion() instead.
Public Methods
static int getXposedVersion()
Returns the currently installed version of the Xposed framework.
static Set<XC_MethodHook.Unhook> hookAllConstructors(Class<?> hookClass, XC_MethodHook callback)
Hook all constructors of the specified class.
static Set<XC_MethodHook.Unhook> hookAllMethods(Class<?> hookClass, String methodName, XC_MethodHook callback)
Hooks all methods with a certain name that were declared in the specified class.
static XC_MethodHook.Unhook hookMethod(Member hookMethod, XC_MethodHook callback)
Hook any method (or constructor) with the specified callback.
static Object invokeOriginalMethod(Member method, Object thisObject, Object[] args)
Basically the same as Method.invoke(Object, Object...), but calls the original method as it was before the interception by Xposed.
static void log(String text)
Writes a message to the Xposed error log.
static void log(Throwable t)
Logs a stack trace to the Xposed error log.
static void unhookMethod(Member hookMethod, XC_MethodHook callback)
This method was deprecated in API level 81. Use XC_MethodHook.Unhook.unhook() instead. An instance of the Unhook class is returned when you hook the method.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final ClassLoader BOOTCLASSLOADER

The system class loader which can be used to locate Android framework classes. Application classes cannot be retrieved from it.

public static int XPOSED_BRIDGE_VERSION

Added in API level 37

This field was deprecated in API level 65.
Use getXposedVersion() instead.

Public Methods

public static int getXposedVersion ()

Added in API level 65

Returns the currently installed version of the Xposed framework.

public static Set<XC_MethodHook.Unhook> hookAllConstructors (Class<?> hookClass, XC_MethodHook callback)

Hook all constructors of the specified class.

Parameters
hookClass The class to check for constructors.
callback The callback to be executed when the hooked constructors are called.
Returns
  • A set containing one object for each found constructor which can be used to unhook it.

public static Set<XC_MethodHook.Unhook> hookAllMethods (Class<?> hookClass, String methodName, XC_MethodHook callback)

Hooks all methods with a certain name that were declared in the specified class. Inherited methods and constructors are not considered. For constructors, use hookAllConstructors(Class, XC_MethodHook) instead.

Parameters
hookClass The class to check for declared methods.
methodName The name of the method(s) to hook.
callback The callback to be executed when the hooked methods are called.
Returns
  • A set containing one object for each found method which can be used to unhook it.

public static XC_MethodHook.Unhook hookMethod (Member hookMethod, XC_MethodHook callback)

Hook any method (or constructor) with the specified callback. See below for some wrappers that make it easier to find a method/constructor in one step.

Parameters
hookMethod The method to be hooked.
callback The callback to be executed when the hooked method is called.
Returns
  • An object that can be used to remove the hook.

public static Object invokeOriginalMethod (Member method, Object thisObject, Object[] args)

Basically the same as Method.invoke(Object, Object...), but calls the original method as it was before the interception by Xposed. Also, access permissions are not checked.

There are very few cases where this method is needed. A common mistake is to replace a method and then invoke the original one based on dynamic conditions. This creates overhead and skips further hooks by other modules. Instead, just hook (don't replace) the method and call param.setResult(null) in XC_MethodHook.beforeHookedMethod(XC_MethodHook.MethodHookParam) if the original method should be skipped.

Parameters
method The method to be called.
thisObject For non-static calls, the "this" pointer, otherwise null.
args Arguments for the method call as Object[] array.
Returns
  • The result returned from the invoked method.
Throws
NullPointerException if receiver == null for a non-static method
IllegalAccessException if this method is not accessible (see AccessibleObject)
IllegalArgumentException if the number of arguments doesn't match the number of parameters, the receiver is incompatible with the declaring class, or an argument could not be unboxed or converted by a widening conversion to the corresponding parameter type
InvocationTargetException if an exception was thrown by the invoked method

public static void log (String text)

Writes a message to the Xposed error log.

DON'T FLOOD THE LOG!!! This is only meant for error logging. If you want to write information/debug messages, use logcat.

Parameters
text The log message.

public static void log (Throwable t)

Logs a stack trace to the Xposed error log.

DON'T FLOOD THE LOG!!! This is only meant for error logging. If you want to write information/debug messages, use logcat.

Parameters
t The Throwable object for the stack trace.

public static void unhookMethod (Member hookMethod, XC_MethodHook callback)

This method was deprecated in API level 81.
Use XC_MethodHook.Unhook.unhook() instead. An instance of the Unhook class is returned when you hook the method.

Removes the callback for a hooked method/constructor.

Parameters
hookMethod The method for which the callback should be removed.
callback The reference to the callback as specified in hookMethod(Member, XC_MethodHook).