38512626 avatar image
0 Votes"
38512626 asked LeonLu-MSFT commented

About camera settings in xamarin forms

I'm running an app created with xamarin forms on an Android device. Even if the location information is turned on with the Android standard camera app, it will be turned off when the camera is called with the created app. Where to check

↓ Set location information to ON with the Android standard camera app

↓ When you start the camera with the created app, the location information is turned off


 <uses-permission android:name="android.permission.CAMERA" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.VIBRATE" />
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />


 [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
 [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
 [assembly: UsesPermission(Android.Manifest.Permission.AccessCoarseLocation)]   
 [assembly: UsesPermission(Android.Manifest.Permission.AccessFineLocation)]    
 [assembly: UsesFeature("android.hardware.location", Required = false)]    
 [assembly: UsesFeature("android.hardware.location.gps", Required = false)]    
 [assembly: UsesFeature("", Required = false)]    
 [assembly: UsesFeature("", Required = false)]    
 [assembly: UsesFeature("", Required = false)]    
 [assembly: UsesPermission(Android.Manifest.Permission.Vibrate)]    
 [assembly: UsesPermission(Android.Manifest.Permission.AccessNetworkState)]    
 [assembly: UsesPermission(Android.Manifest.Permission.AccessMediaLocation)]    
 [assembly: UsesPermission(Android.Manifest.Permission.ReadExternalStorage)]


 private async void OnImageClicked()
         await Plugin.Media.CrossMedia.Current.Initialize();
         if (!Plugin.Media.CrossMedia.Current.IsCameraAvailable || !Plugin.Media.CrossMedia.Current.IsTakePhotoSupported)
         DateTime dt = DateTime.Now;
         string result = dt.ToString("yyyyMMddHHmmss");
         result += ".jpg";
         Plugin.Media.Abstractions.MediaFile file = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
             Name = result
         if (file == null)
         Queue<byte> bytes = new Queue<byte>();
         using (Stream s = file.GetStream())
             long length = s.Length;
             int b;
             while ((b = s.ReadByte()) != -1)
         File.Copy(file.Path, "XXXXXXXXXXXX/Pic");
     catch (Exception)

default.png (1.8 MiB)
original.png (998.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Which API did you used to open the camera? If you custom the Camera with android Camera API, and your application tags images with GPS location information, you must request the ACCESS_FINE_LOCATION permission.

0 Votes 0 ·

0 Answers