protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionLocal; AndroidEnvironment.UnhandledExceptionRaiser += HandleAndroidException; Xamarin.Forms.Forms.Init (this, bundle); Forms.Init(this, bundle); FormsMaps.Init(this, bundle); _locationManager = GetSystemService (Context.LocationService) as LocationManager; Criteria locationCriteria = new Criteria(); locationCriteria.Accuracy = Accuracy.Coarse; locationCriteria.PowerRequirement = Power.Medium; var locationProvider = _locationManager.GetBestProvider(locationCriteria, true); if(locationProvider != null) { _locationManager.RequestLocationUpdates (locationProvider, 500, 1, this); } var pclApp = App.Portable.App.Instance; var setup = new AppSetup () { CreateConnectionPool = this.CreateConnnectionPool, DbPath = Path.Combine (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal),"RF12G5td864.db3") }; pclApp.Setup (setup); #if DEBUG //pclApp.DeleteUser (); #endif LoadApplication (pclApp); }
//TODO: move all database stuff to a session object or factory or something similar public void Setup(AppSetup setup){ var connectionPool = setup.CreateConnectionPool; var connectionString = new SQLite.Net.SQLiteConnectionString (setup.DbPath, true); using (var connection = connectionPool ().GetConnection (connectionString)) { connection.CreateTable<UserInfo> (); connection.Commit (); } //Setup the connection Pool DataAccess.GetConnectionPool = connectionPool; UserDataAccess.DbPath = setup.DbPath; if (IsLoggedIn) { if (!(MainPage is RootPage)) { var rootPage = new RootPage (); Instance.PositionChanged += (object sender, EventArgs e) => rootPage.PositionChanged (); MainPage = rootPage; } } else { MainPage = new LoginPage (); } }