Skip to content

Commit

Permalink
perf: openApp
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge authored and wangxiaoyang08 committed Dec 20, 2024
1 parent 9fe6096 commit f60ad22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/main/kotlin/li/songe/gkd/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private fun ShizukuErrorDialog(stateFlow: MutableStateFlow<Boolean>) {
if (installed) {
TextButton(onClick = {
stateFlow.value = false
app.openApp(appId)
openApp(appId)
}) {
Text(text = "打开 Shizuku")
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/kotlin/li/songe/gkd/util/IntentExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ fun openUri(uri: String) {
app.tryStartActivity(intent)
}

fun Context.openApp(appId: String) {
val intent = packageManager.getLaunchIntentForPackage(appId)
fun openApp(appId: String) {
val intent = app.packageManager.getLaunchIntentForPackage(appId)
if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
tryStartActivity(intent)
app.tryStartActivity(intent)
} else {
toast("请检查此应用是否安装")
}
Expand Down

0 comments on commit f60ad22

Please sign in to comment.