diff --git a/src/App/Platforms/Android/MainActivity.cs b/src/App/Platforms/Android/MainActivity.cs index 88fbceb8c..fe852fc7e 100644 --- a/src/App/Platforms/Android/MainActivity.cs +++ b/src/App/Platforms/Android/MainActivity.cs @@ -76,7 +76,8 @@ namespace Bit.Droid //We need to get and set the Options before calling OnCreate as that will "trigger" CreateWindow on App.xaml.cs _appOptions = GetOptions(); - ((Bit.App.App)Microsoft.Maui.Controls.Application.Current).SetOptions(_appOptions); + //This does not replace existing Options in App.xaml.cs if it exists already. It only updates properties in Options related with Autofill/CreateSend/etc.. + ((Bit.App.App)Microsoft.Maui.Controls.Application.Current).SetAndroidOptions(_appOptions); base.OnCreate(savedInstanceState); diff --git a/src/Core/App.xaml.cs b/src/Core/App.xaml.cs index 4f2fa1b3a..25b882d72 100644 --- a/src/Core/App.xaml.cs +++ b/src/Core/App.xaml.cs @@ -85,10 +85,27 @@ namespace Bit.App } } - //Allows setting Options from MainActivity before base.OnCreate - public void SetOptions(AppOptions appOptions) + /// + /// Allows setting Options from MainActivity before base.OnCreate + /// Note 1: This is only be used by Android due to way it's Lifecycle works + /// Note 2: This method does not replace existing Options in App.xaml.cs if it exists already. + /// It only updates properties in Options related with Autofill/CreateSend/etc.. + /// + /// Options created in Android MainActivity.cs + public void SetAndroidOptions(AppOptions appOptions) { - Options = appOptions ?? new AppOptions(); + if (Options == null) + { + Options = appOptions ?? new AppOptions(); + } + else if(appOptions != null) + { + Options.Uri = appOptions.Uri; + Options.MyVaultTile = appOptions.MyVaultTile; + Options.GeneratorTile = appOptions.GeneratorTile; + Options.FromAutofillFramework = appOptions.FromAutofillFramework; + Options.CreateSend = appOptions.CreateSend; + } } protected override Window CreateWindow(IActivationState activationState)