0

This is a companion question related to this issue:
Delphi - New apps on Google Play must target Android 8 (API level 26) - PUSH notification in background

I am trying to save a bitmap to a "clientName" sub-folder under Android's picture folder.

If I use the original AndroidManifest.template.xml file, everything works as expected. If I use an AndroidManifest.template.xml file patched with 'targetSdkVersion="26"' to meet google's deadline for acceptance into the app store, the same code fails (raises an exception on ".SaveToFile").

Is there any way to get around this issue while Embarcadero works it out internally?

This is the code :

BaseFolder := System.IOUtils.TPath.GetSharedPicturesPath;
If DirectoryExists(BaseFolder) = True then
Begin
  SaveFolder := BaseFolder+System.IOUtils.TPath.DirectorySeparatorChar+clientName;
  If DirectoryExists(SaveFolder) = False then ForceDirectories(SaveFolder);

  SaveFile := SaveFolder+System.IOUtils.TPath.DirectorySeparatorChar+clientName+'_'+ReplaceStr(ReplaceStr(DateTimeToStr(Now),':','.'),'/','.')+saveImageFileExt;
  Try
    bmpCropped.SaveToFile(SaveFile);
  Except
    displayMessage := strErrorSavingPicture;
  End;
  If FileExists(SaveFile) = True then displayMessage := strPictureSaved;
End
Else displayMessage := strPictureFolderNotFound;
bLight
  • 803
  • 7
  • 23
  • You need to implement [runtime permissions](https://stackoverflow.com/questions/46452574/firemonkey-android-read-phone-state-runtime-permission-asks-to-get-imei) However, that is not exactly easy task at the moment and there is QP issue [implement onRequestPermissionsResult in com.embarcadero.firemonkey.FMXNativeActivity](https://quality.embarcadero.com/browse/RSP-20254) – Dalija Prasnikar Jun 13 '18 at 17:57
  • Please detail what the exception is. Use Monitor to see exactly what the OS reports. You might also want to read this: http://delphiworlds.com/2018/05/targeting-android-8-and-higher/ – Dave Nottage Jun 14 '18 at 00:06
  • Going by this: https://stackoverflow.com/questions/39866869/how-to-ask-permission-to-access-gallery-on-android-m you will likely need to request permissions (at run time) for android.permission.READ_EXTERNAL_STORAGE and android.permission.WRITE_EXTERNAL_STORAGE, as per the article I mentioned in my last comment – Dave Nottage Jun 14 '18 at 01:05
  • @DaveNottage Is it even possible now using Delphi code? Looking at Dalija's comment above makes it seem that it may be impossible without help from Embarcadero – bLight Jun 14 '18 at 09:14
  • Yes, it is possible. Read the article I linked to in my first comment – Dave Nottage Jun 14 '18 at 09:16
  • Thanks Dave, I will try to use the work-around if embarcadero doesn't fix it internally by the time I plan on releasing the app. – bLight Jun 14 '18 at 09:35

1 Answers1

0

This issue was resolved with the introduction of Delphi 10.3 which supports runtime permissions.

bLight
  • 803
  • 7
  • 23