Camera Intent - Save captured image to memory only

AugustHerrstrmAugustHerrstrm USMember
edited April 2015 in Xamarin.Android

Hello,

I'm working on a project where i need to be able to take a picture without saving it locally,
For example, i want to be able to take a picture, keep it temporary in memory as a variable and save it as a byte array to a database.

I was able to do this this with Xamarin forms using cross platform code, but i feel the need of doing this natively to get more control of the camera features etc.

Problems so far:
1. Picture are saved to drive, i want it saved temporary in the active view only, as a variable
2. I can't seem to find a way to access the activity result data directly in code without looking for the image with its saved path.

My Dependency Service method as it is right now:

public byte[] TakePicture()
{
        byte[] result = null;
    MainActivity androidContext = (MainActivity)Forms.Context;
    Intent cameraIntent = new Intent(MediaStore.ActionImageCapture);

    PackageManager packageManager = Forms.Context.PackageManager;

    IList<ResolveInfo> activities =
    packageManager.QueryIntentActivities(cameraIntent, 0);

    if (activities.Count == 0)
    {

    }
    else
    {
             androidContext.StartActivityForResult(cameraIntent, 0);
    }

    return result;

}

Forever grateful for helpful responses!
/August

Answers

Sign In or Register to comment.