Forum Xamarin.Forms

Need open camera without media plugin using intent in Android & bind ImageSource to Source in View?

JoannaGJoannaG Member ✭✭✭

I am currently trying to achieve in Xamarin Forms? Didn't get any result so far? Any suggestions ...

Best Answer


  • JoannaGJoannaG Member ✭✭✭
    edited March 2020

    Thanks..Already approaching using dependency service in my app. Though i'm new struggling to achieve this req.
    If i used var/object


    how to solve this.

  • JoannaGJoannaG Member ✭✭✭


  • JoannaGJoannaG Member ✭✭✭
    edited March 2020

    In my AndroidRenderer code.

    public byte[] OpenCapture()
    //List of files from Capture
    var captureCmiFile = new Java.IO.File(baseDir + "/Alden3D/cmi_capture.cmi");
    var captureThumbnailFile = new Java.IO.File(baseDir + "/Alden3D/thumbnail_capture.jpg");
    var capturePreviewFile = new Java.IO.File(baseDir + "/Alden3D/preview_capture.jpg");

            Android.Net.Uri cmiUri = Android.Net.Uri.FromFile(captureCmiFile);
            Android.Net.Uri thumbnailUri = Android.Net.Uri.FromFile(captureThumbnailFile);
            Android.Net.Uri previewUri = Android.Net.Uri.FromFile(capturePreviewFile);
            Intent intent = new Intent("blk3d.intent.action.CAPTURE");
            intent.PutExtra("cmi", cmiUri);
            intent.PutExtra("thumbnail", thumbnailUri);
            intent.PutExtra("preview", previewUri);
            Activity activity = Forms.Context as Activity;
            activity.StartActivityForResult(intent, 151)
            return ????;   /////how do i get value for byte[] array

    Here's is my MainActivity,
    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
    base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == 151)
                if (resultCode == Result.Ok)
                    var test = data.HasExtra("cmi");
                    cmiUri = (Android.Net.Uri) data.GetParcelableExtra("cmi");
                    previewUri = (Android.Net.Uri)data.GetParcelableExtra("preview");
                    thumbnailUri = (Android.Net.Uri)data.GetParcelableExtra("thumbnail"); // **i need to pass from here to my renderer class**
                    Toast.MakeText(this, "Success.", ToastLength.Short).Show();
                    Toast.MakeText(this, " - Unable to capture now. Try again later.", ToastLength.Short).Show();
  • YelinzhYelinzh Member, Xamarin Team Xamurai

    If you've solved the issue, please mark the helpful reply as the answer. It'll help others who face the similar problem.

Sign In or Register to comment.