about summary refs log tree commit diff
path: root/plugins/withAndroidManifestLaunchModePlugin.js
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/withAndroidManifestLaunchModePlugin.js')
-rw-r--r--plugins/withAndroidManifestLaunchModePlugin.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/withAndroidManifestLaunchModePlugin.js b/plugins/withAndroidManifestLaunchModePlugin.js
new file mode 100644
index 000000000..45ab9aeb7
--- /dev/null
+++ b/plugins/withAndroidManifestLaunchModePlugin.js
@@ -0,0 +1,17 @@
+const {withAndroidManifest} = require('expo/config-plugins')
+
+module.exports = function withAndroidManifestLaunchModePlugin(appConfig) {
+  return withAndroidManifest(appConfig, function (decoratedAppConfig) {
+    try {
+      const mainApplication =
+        decoratedAppConfig.modResults.manifest.application[0]
+      const mainActivity = mainApplication.activity.find(
+        elem => elem.$['android:name'] === '.MainActivity',
+      )
+      mainActivity.$['android:launchMode'] = 'singleTop'
+    } catch (e) {
+      console.error(`withAndroidManifestLaunchModePlugin failed`, e)
+    }
+    return decoratedAppConfig
+  })
+}