Hi Having a problem while trying to take a image using the camera. Whenever i deploy a fresh install of the app. Open the app. Try to take a photo the permission dialog opens it asks for
"Allow to access photos, media and files" but there is no camera
image
I have the camera permission in the Android Manifest
I also have
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
in the MainActivity Class
the code thats taking the photo
private async void TakePhotoIDImage(object sender, EventArgs e)
{
//var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);
//if (status == PermissionStatus.Granted)
//{
//}
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
await DisplayAlert("No Camera", ":( No camera available.", "OK");
return;
}
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
PhotoSize = PhotoSize.Medium,
});
if (file == null)
return;
using (var memoryStream = new MemoryStream())
{
file.GetStream().CopyTo(memoryStream);
var myfile = memoryStream.ToArray();
mysfile = myfile;
}
PhotoIDImage.Source = ImageSource.FromFile(file.Path);
}
The app always crashes then i need to goto the phones settings -> app -> and manually set the camera permission to true before i can start testing the app which is obviously not the right way.
I've had it working on another app and comparing the settings they are exactly the same and also using on the same device.
I have also set the Compile and Target Android to API Level 23 but still no go.
always getting a permission error in the output. The error on the output window is
Does not have storage permission granted, requesting.
Java.Lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity clip={text/uri-list U:file:///storage/emulated/0/Android/data/SavR.SavR/files/Pictures/IMG_20170628_111109.jpg} (has extras) } from ProcessRecord{c28c0d6 28331:SavR.SavR/u0a245} (pid=28331, uid=10245) with revoked permission android.permission.CAMERA
any thoughts ??