private async Task Save(byte[] bytes) { using (OutputStream output = new FileOutputStream(File)) { output.Write(bytes); } global::Android.Graphics.Bitmap bitmap = global::Android.Graphics.BitmapFactory.DecodeFile(File.AbsolutePath); ExifInterface exif = new ExifInterface(File.AbsolutePath); string orientation = exif.GetAttribute(ExifInterface.TagOrientation); switch (orientation) { case "6": bitmap = Camera1Fragment.Rotate(bitmap, 90); break; case "8": bitmap = Camera1Fragment.Rotate(bitmap, 270); break; case "3": bitmap = Camera1Fragment.Rotate(bitmap, 180); break; } await AndroidUtils.WriteBitmapToFile(File.AbsolutePath, bitmap); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.CameraActivity); string jsonData = Intent.GetStringExtra("JSON") ?? ""; learningTask = JsonConvert.DeserializeObject <AppTask>(jsonData, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); activityId = Intent.GetIntExtra("ACTID", -1); if (bundle == null) { if (learningTask.TaskType.IdName == "TAKE_VIDEO") { RequestedOrientation = ScreenOrientation.Landscape; if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera2VideoFragment.NewInstance()).Commit(); } else { FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera1VideoFragment.NewInstance()).Commit(); } } else { if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera2Fragment.NewInstance()).Commit(); } else { FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera1Fragment.NewInstance()).Commit(); } } } if (!AndroidUtils.IsGooglePlayServicesInstalled(this) || googleApiClient != null) { return; } googleApiClient = new GoogleApiClient.Builder(this) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi(LocationServices.API) .Build(); locRequest = new LocationRequest(); }