Skip to content

Camera capture intent always returning NULL and the resultCode as CANCELED on android 11 #6778

@santosh-qas

Description

@santosh-qas

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.), Android for .NET (net6.0-android, etc.)

Affected platform version

Android 11

Description

In my xamaring android application using camera capture intent to capture the image and upload it. However the intent is returned as null.

My code is like

///////**********  Cameracapture code
Intent camIntent= new Intent(MediaStore.ActionImageCapture);
var file = new File(imageStorageDir + File.Separator + "IMG_" + DateTime.Now.Ticks + ".jpg");
                           var  mPhotoUri = Android.Net.Uri.FromFile(file);
                            camIntent.PutExtra(MediaStore.ExtraOutput, mPhotoUri); 
File imageStorageDir = new File(DownloadDirectory, DOWNLOAD_FOLDER);
                            StartActivityForResult(camIntent, 0); 



////////******** MainActivity

protected override void OnActivityResult(int requestCode, Result resultCode, Intent intent)
{
   
	if (intent != null && intent.DataString != null)
	{
		// my logic when image captured goes here. But image is not being captured
		// Here the intent is always received as null and resultCode as CANCELED
	}
}

Steps to Reproduce

  1. Select camera when prompted from intent
  2. Capture Image
  3. Select captured Image

Did you find any workaround?

No as of now.

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Area: Mono.AndroidIssues with the Android API binding (Mono.Android.dll).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions