also looking at this
fix(android): skip the whole launch intent on a relaunch from Recents
#240
2 files
+51
-9
| @@ -46,18 +46,25 @@ class MainActivity : AppCompatActivity() { | ||
| 46 | 46 | craftBridge = CraftBridge(this, webView, CraftHealthConnect(this, webView)) |
| 47 | 47 | // The link that launched the app (#215). Queued until the page's bridge |
| 48 | 48 | // 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 | |
| 53 | 60 | 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 | } | |
| 57 | 65 | } else { |
| 58 | 66 | craftBridge.restoreDeepLinks(savedInstanceState) |
| 59 | 67 | } |
| 60 | if (savedInstanceState == null) handleIncomingShortcut(intent) | |
| 61 | 68 | |
| 62 | 69 | setupWebView() |
| 63 | 70 | loadContent() |