Using the Camera on Android

Shows how to use the Camera on Android.

Add these two to the AndroidManifest.android-xml:

  <uses-permission android:name="android.permission.CAMERA" />
  <uses-feature android:name="android.hardware.camera" />

In your Activity, add:

public const int RequestCode = 100;
...
  // Code to trigger the camera capturing:
  var intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  startActivityForResult(intent, RequestCode);

// This gets called when the capturing is done.
protected override void onActivityResult(int requestCode, int resultCode, Intent data)
{
	if (requestCode == RequestCode)
	{
		var bitmap = (android.graphics.Bitmap)data.getExtras().get("data");
		// bitmap contains the image captured.
	}
}

More info can be found here

1 Like