编写Xposed框架初体验
具体步骤:
- 修改配置文件,添加xposed插件相关数据。在AndroidManifest.xml中添加以下代码:
<!--添加标识-->
<meta-data
android:name="xposedmodule"
android:value="true"/>
<!--载入HOOK模块之后显示的信息-->
<meta-data
android:name="xposeddescription"
android:value="Xposed框架初体验"/>
<!--规定jar包的版本信息-->
<meta-data
android:name="xposedminversion"
android:value="54"/>
2、新建lib文件夹,将Xposed框架提供的jar包放到此文件夹中。具体流程:右击app->new->Directory->输入lib->将jar包复制到此文件夹中->右击文件夹->Add as Library->在build.gradle中将implementation改为compileOnly files。
3、新建一个类Xposedhook实现IXposedHookLoadPackage接口。
import android.util.Log;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
public class Xposedhook implements IXposedHookLoadPackage {
//Xposed插件入口点
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam Param) throws Throwable {
XposedBridge.log("cly hook start------->当前启动的程序是:"+Param.processName);
Log.d("L61q4_Cheng", "hook Start......");
}
}
4、在Main/assets中新建一个文本文件xposed_init,并在其中添加新建的类,包名加类名,
com.example.xposed_new3.Xposedhook
5、编译成apk并运行,在xposed Installer中查看日志。