//[...]
repositories{jcenter()}dependencies{// Xposed Framework API dependencies
compileOnly'de.robv.android.xposed:api:82'compileOnly'de.robv.android.xposed:api:82:sources'}
Set manifest.xml:
<manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.test.app.hook"><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/AppTheme"><meta-dataandroid:name="xposedmodule"android:value="true"/><meta-dataandroid:name="xposeddescription"android:value="Hook for Application"/><meta-dataandroid:name="xposedminversion"android:value="53"/></application></manifest>
Create a new Class
Create a directory called assets in app/src/main
Create a new text document called xposed_init in app/src/main/assets
packagede.robv.android.xposed.mods.tutorial;importstaticde.robv.android.xposed.XposedHelpers.findAndHookMethod;importandroid.graphics.Color;importandroid.widget.TextView;importde.robv.android.xposed.IXposedHookLoadPackage;importde.robv.android.xposed.XC_MethodHook;importde.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;publicclassTutorialimplementsIXposedHookLoadPackage{//Is loaded when each app starts
publicvoidhandleLoadPackage(finalLoadPackageParamlpparam)throwsThrowable{//Only Hook the com.android.systemui application
if(!lpparam.packageName.equals("com.android.systemui"))return;//Change the behavor of the specified function with no arguments
findAndHookMethod("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader,"updateClock",newXC_MethodHook(){@OverrideprotectedvoidafterHookedMethod(MethodHookParamparam)throwsThrowable{TextView tv =(TextView) param.thisObject;String text = tv.getText().toString();
tv.setText(text +" :)");
tv.setTextColor(Color.RED);}});}}
findAndHookMethod("javax.net.ssl.HttpsURLConnection", lpparam.classLoader,"setDefaultHostnameVerifier",HostnameVerifier.class,newXC_MethodReplacement(){//Replace the Method with your own
@OverrideprotectedObjectreplaceHookedMethod(MethodHookParamparam)throwsThrowable{returnnull;}});
Once the hook is written, the project needs to be compiled into a signed APK and installed on the device (e.g., via “adb install”).