Change Android's MainActivity launchMode to singleTop (#4255)
* Add build config plugin to set .MainActivity launchMode * Change android:launchMode to standard * Revert "Change android:launchMode to standard" This reverts commit fddbc4e1b512ff9a55009e227f1f44e99ddabaf3. * adjust --------- Co-authored-by: Hailey <me@haileyok.com>
This commit is contained in:
parent
33de856c32
commit
65ad16e394
3 changed files with 20 additions and 2 deletions
17
plugins/withAndroidManifestLaunchModePlugin.js
Normal file
17
plugins/withAndroidManifestLaunchModePlugin.js
Normal file
|
@ -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
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue