Introduction to the
Xposed is a hook framework running on the Android operating system. By replacing the key files of the Android system, it can intercept almost all the Java function calls, and allows the custom code in the Xposed module to change the behavior when calling these functions. Therefore, Xposed is often used to modify the Android system and application function.
Configuring Module Information
Open androidManifest.xml and add three meta-data tags to the Application. Xposedmodule stands for this is an Xposed module. Xposeddescription represents the module description and is displayed in module management. Xposedminversion represents the lowest version of Xposed supported.
<? The XML version = "1.0" encoding = "utf-8"? > <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.robv.android.xposed.mods.tutorial" Android :versionCode="1" Android :versionName="1.0" > <uses-sdk Android :minSdkVersion="15" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <meta-data android:name="xposedmodule" android:value="true" /> <meta-data android:name="xposeddescription" android:value="Easy example which makes the status bar clock red and adds a smiley" /> <meta-data android:name="xposedminversion" android:value="53" /> </application> </manifest>Copy the code
Add the dependent
Add the following code to the build.gradle of the main project (usually called app)
dependencies {
............
compileOnly 'de.robv.android.xposed:api:82'
compileOnly 'de.robv.android.xposed:api:82:sources'
}
Copy the code
Then synchronize, after the success of synchronization, you can use Xposed Api in the code.
Create entry class
Implement the IXposedHookLoadPackage interface.
package de.robv.android.xposed.mods.tutorial; import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam; public class Tutorial implements IXposedHookLoadPackage { public void handleLoadPackage(final LoadPackageParam lpparam) Throws Throwable {// Handle hook logic xposedbridge. log("Loaded app: "+ lpparam.packagename); / / using XposedHelpers findAndHookMethod method such as hook}}Copy the code
Add the initialization file
Create a text file called xposed_init in the assets directory. If there is no assets directory, create the assets directory first. Content is the full path to the entry class
de.robv.android.xposed.mods.tutorial.Tutorial
Copy the code
Great work, run the project, will see our APP in the Xposed module management.