protected override void OnCreate(Bundle bundle) { // Set our view from the "main" layout resource startPostingService(); base.OnCreate(bundle); SetContentView(Resource.Layout.Main); // Initializing Elements Initialize(); // Show the mapFragment // fm.BeginTransaction().Show(mapFrag); Android.App.FragmentTransaction t = FragmentManager.BeginTransaction(); t.Show(mapFrag); t.Commit(); // Checking Permissions if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) != (int)Permission.Granted) { RequestLocationPermission(); } else { mapFrag.GetMapAsync(this); // Starting Location Service App.StartLocationService(); } }
private void switchtoMap() { updateToggle.Visibility = ViewStates.Invisible; Fab2.SetVisibility(ViewStates.Visible); // Removing other fragments /* foreach (Android.App.Fragment f in FragmentList) * { * fm.BeginTransaction().Hide(f).Commit(); * fm.BeginTransaction().Remove(f).Commit(); * }*/ Android.App.FragmentTransaction t = FragmentManager.BeginTransaction(); //t.Replace(Resource.Id.content_frame, mapFrag); // t.AddToBackStack(null); foreach (Android.App.Fragment f in FragmentList) { if (f != mapFrag) { t.Hide(f); } } t.Show(mapFrag); t.Commit(); // Getting the map mapFrag.GetMapAsync(this); // Showing the map fragment // fm.BeginTransaction().Show(mapFrag).Commit(); // If location isn't null AND map has been initialized (the location service can start updating before Location location = LocationServices.FusedLocationApi.GetLastLocation(apiClient); if (location != null && MyMap != null) { CameraUpdate center = CameraUpdateFactory.NewLatLng(new LatLng(location.Latitude, location.Longitude)); MyMap.MoveCamera(center); } }
private void switchtoSensorFragment() { updateToggle.Visibility = ViewStates.Invisible; Fab2.SetVisibility(ViewStates.Invisible); Android.App.FragmentTransaction t = FragmentManager.BeginTransaction(); t.Replace(Resource.Id.content_frame, senFrag); foreach (Android.App.Fragment f in FragmentList) { if (f != senFrag) { t.Hide(f); } } t.Show(senFrag); t.Commit(); // fm.BeginTransaction().Replace(Resource.Id.content_frame, senFrag).Commit(); // fm.BeginTransaction().Show(senFrag).Commit(); }