- Xposed API wrapper for Kotlin
- In project root directory
git submodule add -b <branch> 'https://github.com/Mufanc/EasyHook' easyhook
include(
":easyhook:api",
":easyhook:ksp-xposed"
)
- In project
build.gradle.kts
val applicationModuleName by extra(":app") // replace with your app module name
- In module
build.gradle.kts
plugins {
id("com.google.devtools.ksp") version "<version>"
}
dependencies {
implementation(project(":easyhook:api"))
ksp(project(":easyhook:ksp-xposed"))
}
class HookEntry : IXposedHookLoadPackage {
companion object {
const val TAG = "CustomTAG"
}
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
if (lpparam.packageName == BuildConfig.APPLICATION_ID) {
XposedHelpers.findAndHookMethod(
Activity::class.java,
"onCreate",
Bundle::class.java,
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam?) {
Log.i(TAG, "Activity created!")
}
}
)
}
}
}
@XposedEntry
class HookEntry : HookHelper("CustomTAG") {
override fun onHook() = handle {
onLoadPackage(BuildConfig.APPLICATION_ID) {
Activity::class.java.hook {
method({ name == "onCreate" }) {
Logger.i("Activity created!")
}
}
}
}
}