Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

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

Answers

  • JoannaGJoannaG Member ✭✭
    edited March 5

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

    else

    how to solve this.

  • JoannaGJoannaG Member ✭✭


    Casted!!....

  • JoannaGJoannaG Member ✭✭
    edited March 5

    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();
                }
                else
                {
                    Toast.MakeText(this, " - Unable to capture now. Try again later.", ToastLength.Short).Show();
                }
            }
        }
    
  • JarvanJarvan 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.