How to save a Canvas image and show it in Gallery on all Android version

Here you have the blocks to save an image with Canvas and display it in the Gallery on all Android versions.

Note: This is currently not possible with the File component due to its known bug regarding storage permissions on Android 11+. So we have to use one of File extensions from @Taifun or @vknow360.

Blocks

To check this on different devices & Android version: canvasGallery.apk - Google Drive

How does it work:

  1. Check the API level and if < 30, request WRITE permission.
  2. Save the canvas image in the ASD (→ DefaultFileScope = App)
  3. Move the image from the ASD to /Pictures (Shared folder) using TaifunFile.
  4. Display the image with the Image component.
  5. Refresh Gallery using TaifunTools ext.
  6. When the app is closed, the image will be deleted (reason: see note in blocks).

On Android 11+ it should work without any storage permissions.

6 Likes