ReviewOS

also looking at this

craft-native/craft

fix(android): skip the whole launch intent on a relaunch from Recents

#240
Merged glennmichael123 wants to merge fix/android-recents-relaunch into main
2 files +51 -9
packages/android/templates/MainActivity.kt.templatemodified+15-8
Changes to packages/android/templates/MainActivity.kt.template
@@ -46,18 +46,25 @@ class MainActivity : AppCompatActivity() {
4646 craftBridge = CraftBridge(this, webView, CraftHealthConnect(this, webView))
4747 // The link that launched the app (#215). Queued until the page's bridge
4848 // is injected, then dispatched once with `initial: true`, so a page that
49 // subscribes rather than calling getInitialURL still hears it. A
50 // relaunch from Recents carries the old intent, and was not opened by it.
51 // A recreated activity restores what the bridge saved: its intent may
52 // be a later warm link that onNewIntent set.
49 // subscribes rather than calling getInitialURL still hears it.
50 //
51 // A relaunch from Recents carries the intent the app was first opened
52 // with. The person picked the task out of a list, not the link or the
53 // shortcut inside it, and neither is news the second time — so both
54 // are skipped, not just the link (#229).
55 //
56 // A recreated activity restores what the bridge saved rather than
57 // reading its intent, which onNewIntent may have replaced with a
58 // later warm link.
59 val launchedFromHistory = intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY != 0
5360 if (savedInstanceState == null) {
54 val launchLink = intent.data?.toString()
55 val launchedFromHistory = intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY != 0
56 if (launchLink != null && !launchedFromHistory) craftBridge.receiveDeepLink(launchLink)
61 if (!launchedFromHistory) {
62 intent.data?.toString()?.let(craftBridge::receiveDeepLink)
63 handleIncomingShortcut(intent)
64 }
5765 } else {
5866 craftBridge.restoreDeepLinks(savedInstanceState)
5967 }
60 if (savedInstanceState == null) handleIncomingShortcut(intent)
6168
6269 setupWebView()
6370 loadContent()