强制退出

This commit is contained in:
fengge 2026-06-18 15:13:18 +08:00
parent 8a7531428b
commit 9d5f4dc3a9
1 changed files with 12 additions and 0 deletions

View File

@ -75,6 +75,7 @@ class AndroidInterface(private val activity: MainActivity) {
"printRawData" -> { printRawData(optStringOrNull(args, 0)); "" }
"startUpdate" -> { startUpdate(optStringOrNull(args, 0)); "" }
"exitApp" -> { exitApp(); "" }
"forceExit" -> { forceExit(); "" }
"getVersionName" -> getVersionName()
"getAboutInfo" -> getAboutInfo()
"saveMessage" -> { saveMessage(optStringOrNull(args, 0)); "" }
@ -365,6 +366,17 @@ class AndroidInterface(private val activity: MainActivity) {
}
}
fun forceExit() {
Handler(Looper.getMainLooper()).post {
try {
com.stand.standapp.utils.AppKiller.killApp(activity)
} catch (e: Exception) {
Timber.tag("App").e(e, "强制退出失败")
activity.finish()
}
}
}
fun getVersionName(): String {
return try {
val packageInfo = activity.packageManager.getPackageInfo(activity.packageName, 0)