Restart your application programmatically, compact for Android 10(API level 29)
window background | homepage | restart homepage |
---|---|---|
Add maven repo and library dependency:
repositories {
maven {
url = uri("https://maven.pkg.github.com/hacktons/zygote")
}
}
dependencies {
implementation("cn.hacktons:zygote:1.0.0")
}
Kill process directly:
App.restart(context)
Kill process by yourself:
App.restart(context) {
Log.i(tag, "do some clean task, such as flush pending log request")
// TODO xxx
Process.killProcess(Process.myPid())
}
Restart main process via sub-process instead of AlarmManager.