Skip to content

Commit c07fa07

Browse files
committed
[[ Bug 23212 ]] Ask for proper permission before "mobileExportImageToAlbum"
This patch ensures the permission to access "Files and Media" is requested by the user before calling "mobileExportImageToAlbum". This fixes a silent failure on Android 7+ devices.
1 parent 039113d commit c07fa07

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/notes/bugfix-23212.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure `mobileExportImageToAlbum` works on Android 7+ devices

engine/src/mblandroidmisc.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,10 @@ bool MCSystemExportImageToAlbum(MCStringRef& r_save_result, MCDataRef p_raw_data
739739
// SN-2015-01-05: [[ Bug 11417 ]] The file extension has a trailing '\n', which causes issues on Android.
740740
MCAutoStringRef t_android_filetype;
741741
MCStringCopySubstring(p_file_extension, MCRangeMake(0, MCStringGetLength(p_file_extension) - 1), &t_android_filetype);
742+
743+
if (!MCAndroidCheckRuntimePermission(MCSTR("android.permission.WRITE_EXTERNAL_STORAGE")))
744+
return false;
745+
742746
MCAndroidEngineCall("exportImageToAlbum", "xdxx", &r_save_result, p_raw_data, p_file_name, *t_android_filetype);
743747

744748
return true;

0 commit comments

Comments
 (0)