protected override async void OnResume() { base.OnResume(); int itemId = Intent.GetIntExtra(ShareItemIdExtraName, 0); if (itemId > 0) { shareItem = App.Database.GetItem(itemId); fileName = shareItem.ImagePath; System.Console.WriteLine("Image path: " + fileName); Bitmap b = BitmapFactory.DecodeFile(fileName); // Display the bitmap photoImageView.SetImageBitmap(b); locationText.Text = shareItem.Location; return; } if (fileName == "") { fileName = "in-progress"; var picker = new MediaPicker(this); // new MediaPicker (); on iOS if (!picker.IsCameraAvailable) { System.Console.WriteLine("No camera!"); } else { var options = new StoreCameraMediaOptions { Name = DateTime.Now.ToString("yyyyMMddHHmmss"), Directory = "MediaPickerSample" }; #if !VISUALSTUDIO #region new style if (!picker.IsCameraAvailable || !picker.PhotosSupported) { ShowUnsupported(); return; } Intent intent = picker.GetTakePhotoUI(options); StartActivityForResult(intent, 1); #endregion #else #region old style (deprecated) var t = picker.TakePhotoAsync(options); await t; if (t.IsCanceled) { System.Console.WriteLine("User canceled"); fileName = "cancelled"; // TODO: return to main screen StartActivity(typeof(MainScreen)); return; } System.Console.WriteLine(t.Result.Path); fileName = t.Result.Path; fileNameThumb = fileName.Replace(".jpg", "_thumb.jpg"); Bitmap b = BitmapFactory.DecodeFile(fileName); RunOnUiThread(() => { // Display the bitmap photoImageView.SetImageBitmap(b); // Cleanup any resources held by the MediaFile instance t.Result.Dispose(); }); var boptions = new BitmapFactory.Options { OutHeight = 128, OutWidth = 128 }; var newBitmap = await BitmapFactory.DecodeFileAsync(fileName, boptions); var @out = new System.IO.FileStream(fileNameThumb, System.IO.FileMode.Create); newBitmap.Compress(Android.Graphics.Bitmap.CompressFormat.Jpeg, 90, @out); //}); #endregion #endif } } try { var locator = new Geolocator(this) { DesiredAccuracy = 50 }; // new Geolocator () { ... }; on iOS var position = await locator.GetPositionAsync(timeout : 10000); System.Console.WriteLine("Position Latitude: {0}", position.Latitude); System.Console.WriteLine("Position Longitude: {0}", position.Longitude); location = string.Format("{0},{1}", position.Latitude, position.Longitude); locationText.Text = location; } catch (Exception e) { System.Console.WriteLine("Position Exception: " + e.Message); } }
protected override async void OnResume() { base.OnResume(); int itemId = Intent.GetIntExtra(ShareItemIdExtraName, 0); if (itemId > 0) { shareItem = App.Database.GetItem(itemId); fileName = shareItem.ImagePath; Console.WriteLine("Image path: {0}", fileName); Bitmap b = BitmapFactory.DecodeFile(fileName); // Display the bitmap photoImageView.SetImageBitmap(b); locationText.Text = shareItem.Location; return; } if (string.IsNullOrEmpty(fileName)) { fileName = "in-progress"; var picker = new MediaPicker(this); if (!picker.IsCameraAvailable) { Console.WriteLine("No camera!"); } else { var options = new StoreCameraMediaOptions { Name = DateTime.Now.ToString("yyyyMMddHHmmss"), Directory = "MediaPickerSample" }; if (!picker.IsCameraAvailable || !picker.PhotosSupported) { ShowUnsupported(); return; } Intent intent = picker.GetTakePhotoUI(options); StartActivityForResult(intent, 1); } } else { SetImage(); } try { var locator = new Geolocator(this) { DesiredAccuracy = 50 }; var position = await locator.GetPositionAsync(10000); Console.WriteLine("Position Latitude: {0}", position.Latitude); Console.WriteLine("Position Longitude: {0}", position.Longitude); location = string.Format("{0},{1}", position.Latitude, position.Longitude); locationText.Text = location; } catch (Exception e) { Console.WriteLine("Position Exception: {0}", e.Message); } }
private void InitServices() { _dispatchService = IocContainer.GetContainer().Resolve<IDispatcherService>() as DispatcherService; _navigationService = IocContainer.GetContainer().Resolve<IExtendedNavigationService>() as ExtendedNavigationService; _dialogService = IocContainer.GetContainer().Resolve<IExtendedDialogService>() as ExtendedDialogService; _hudService = IocContainer.GetContainer().Resolve<IHudService>() as HudService; _browserService = IocContainer.GetContainer().Resolve<IBrowserService>() as BrowserService; _geoLocator = IocContainer.GetContainer().Resolve<IGeolocator>() as Geolocator; _connectivityService = IocContainer.GetContainer().Resolve<IConnectivityService>() as ConnectivityService; _phoneService = IocContainer.GetContainer().Resolve<IPhoneService>() as PhoneService; _mapService = IocContainer.GetContainer().Resolve<IMapService>() as MapService; _emailService = IocContainer.GetContainer().Resolve<IEmailService>() as EmailService; _twitterHelper = IocContainer.GetContainer().Resolve<ITwitterHelper>() as AndroidTwitterHelper; _facebookHelper = IocContainer.GetContainer().Resolve<IFacebookHelper>() as AndroidFacebookHelper; }