diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 2f56710e4..8ed15b12f 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -17,6 +17,7 @@ using Bit.Core.Enums; using Android.Nfc; using Bit.App.Utilities; using System.Threading.Tasks; +using Android.Support.V4.Content; namespace Bit.Droid { @@ -202,9 +203,8 @@ namespace Bit.Droid else { // camera - var root = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory, "bitwarden"); - var file = new Java.IO.File(root, "temp_camera_photo.jpg"); - uri = Android.Net.Uri.FromFile(file); + var file = new Java.IO.File(GetExternalFilesDir("temp"), "camera_photo.jpg"); + uri = FileProvider.GetUriForFile(this, "com.x8bit.bitwarden.fileprovider", file); fileName = $"photo_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.jpg"; } diff --git a/src/Android/Resources/xml/filepaths.xml b/src/Android/Resources/xml/filepaths.xml index 3ae5d6901..030c83b5e 100644 --- a/src/Android/Resources/xml/filepaths.xml +++ b/src/Android/Resources/xml/filepaths.xml @@ -1,4 +1,5 @@  + diff --git a/src/Android/Services/DeviceActionService.cs b/src/Android/Services/DeviceActionService.cs index aec778f1c..d0e6e2f0b 100644 --- a/src/Android/Services/DeviceActionService.cs +++ b/src/Android/Services/DeviceActionService.cs @@ -201,14 +201,14 @@ namespace Bit.Droid.Services { try { - var root = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory, "bitwarden"); - var file = new Java.IO.File(root, "temp_camera_photo.jpg"); + var file = new Java.IO.File(activity.GetExternalFilesDir("temp"), "camera_photo.jpg"); if(!file.Exists()) { file.ParentFile.Mkdirs(); file.CreateNewFile(); } - var outputFileUri = Android.Net.Uri.FromFile(file); + var outputFileUri = FileProvider.GetUriForFile(activity, + "com.x8bit.bitwarden.fileprovider", file); additionalIntents.AddRange(GetCameraIntents(outputFileUri)); } catch(Java.IO.IOException) { }