using System; using Android.App; using Android.Content.PM; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using Microsoft.Practices.Unity; using Bit.App.Abstractions; using Bit.App.Services; using XLabs.Ioc.Unity; using XLabs.Ioc; using Bit.Android.Services; using Plugin.Settings; using Plugin.Connectivity; using Acr.UserDialogs; namespace Bit.Android { [Activity(Label = "bitwarden", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); if(!Resolver.IsSet) { SetIoc(); } LoadApplication(new App.App(Resolver.Resolve(), Resolver.Resolve())); } private void SetIoc() { var container = new UnityContainer(); container .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) .RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager()); Resolver.SetResolver(new UnityResolver(container)); UserDialogs.Init(this); } } }