Skip to content

Commit fe04b1a

Browse files
committed
Fix launching NavDeepLink Intent
1 parent a1a52a1 commit fe04b1a

File tree

1 file changed

+11
-7
lines changed
  • app/src/main/java/org/fcitx/fcitx5/android/utils

1 file changed

+11
-7
lines changed

app/src/main/java/org/fcitx/fcitx5/android/utils/AppUtil.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ object AppUtil {
2121
fun launchMain(context: Context) {
2222
context.startActivity(
2323
Intent(context, MainActivity::class.java).apply {
24-
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
25-
addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
24+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
2625
}
2726
)
2827
}
@@ -32,11 +31,16 @@ object AppUtil {
3231
.setComponentName(MainActivity::class.java)
3332
.setGraph(R.navigation.settings_nav)
3433
.addDestination(dest, arguments)
35-
.createPendingIntent()
36-
.send(context, 0, Intent().apply {
37-
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
38-
addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
39-
})
34+
.createTaskStackBuilder()
35+
/**
36+
* [androidx.core.app.TaskStackBuilder.getIntents] would add unwanted flags
37+
* [Intent.FLAG_ACTIVITY_CLEAR_TASK] and [Intent.FLAG_ACTIVITY_TASK_ON_HOME]
38+
* so we must launch the Intent by ourselves
39+
*/
40+
.editIntentAt(0)?.apply {
41+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
42+
context.startActivity(this)
43+
}
4044
}
4145

4246
fun launchMainToKeyboard(context: Context) =

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy