locked
Xamarin Forms Android Camera not working after update Android OS 11 RRS feed

All replies

  • User166490 posted

    Working Code:

    ``` var filePath = Droid.MainActivity.Instance.GetExternalFilesDir(Android.OS.Environment.DirectoryPictures).Path; Java.IO.File file;

    private void TakeAPicture(object sender, EventArgs eventArgs) { var intent = new Intent(MediaStore.ActionImageCapture);

    file = new Java.IO.File(filePath, string.Format("Image_{0}.jpg", Guid.NewGuid())); (new Java.IO.File(filePath)).SetWritable(true, false); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(file)); StartActivityForResult(intent, 102); }

    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { if (requestCode == 102 && resultCode == Result.Ok) { byte[] imageByteArray = Utils.HandleRotationBitmap.GetRotatedImageByteArray(Forms.Context, file); if (imageByteArray != null) { ImgView.SetImageBitmap(imageByteArray); } else { //NULL } } } ```

    Tuesday, October 6, 2020 7:01 AM
  • User28214 posted

    Did you ever find a solution to this issue? I'm facing the same issue after updating to the Android 11 sdk.

    Monday, March 29, 2021 3:04 PM