Saving Canvas to Internal Storage

Show your final blocks (especially the .GalleryRefesh block).

hello! my current final blocks would be as TIMAI2 pasted.

Not too sure why I couldn’t get the .GalleryRefresh to work for me as I attempted to adapt the solutions to the many existing threads that either you or taifun had given advice on :sweat_smile:

I don't see a Gallery refresh block there. So show your blocks (all).

Hi! I've tried to incorporate the Gallery Refresh block as such, the canvas image still doesn't appear in my gallery immediately though...

Thanks everyone for their input! After cross-referencing with even more posts about the Gallery Refresh method (such as this Refresh Gallery).

I managed to get the images to update directly using these as the final blocks

As I pointed out several times in the last years, the .RefreshGallery method doesn't work with a full path nor a relative path. You must use an absolute path.


@Taifun might want to explain the reason for this (after all these years and countless questions).

I'm missing some permissions blocks for Android 11+, 13+ and Android < 11.

Reading the documentation would have helped...

Gallery Refresh for a specific filename. Note : you will have to use an absolute path to the file, for example /storage/emulated/0/DCIM/myImage.jpg , Returns the filename.

Thank you for using the tools extension

That's the wrong question
The correct question is, why @chonker did not consider to read the documentation...
If you are tired to answer those questions, just don't do it

Taifun

Hello! I’m fairly new to this hence I didn’t quite understand the documentation (tried to download and run the sample sia attached in the documentation but it didn’t quite work) hence I was asking for advice :sweat_smile:

Thank you for the reply though and everyone else for the help!

I don't think so, because I find it interesting to know the reason why it only works with an absolute path. AFAIK there is no path restriction in any other of your extensions.

Let me know how to improve it

Great! I will check the example, probably it needs an update

Taifun

This post is about saving a Canvas Image to the device's internal storage.

" Saving Canvas to Internal Storage" suggests saving to a database, e.g. ordinates and colours etc of geometry (which could therfore be re-drawn on reload of the App).

Hi Taifun, I downloaded and used the 'refresh.aia' from your site but the gallery does not refresh. I have then restarted my phone, even then the gallery does not refresh. My phone is running the latest Android version. Would you be able to look at your code for 'refresh.aia'.

Thanks

To be able to see an image in the Gallery, it must be stored in shared storage

Just set default file scope in the project properties to Legacy and use the Canvas.SaveAs method together with path /Download/canvas.jpg

Taifun
PS: yes, the example needs an update

Thanks Taifun, I have updated the app as per your recommendations. On saving the canvas, the gallery still does not refresh on its own, I have to restart the phone for the jpg to appear in the download folder. This is ok for one off instance but is not practical for an app which outputs jpg files. Could I request a review of the gallery refresh method on AI2 ?

Using the FilePicker component should always find it ?

Try this one:
refresh_Anke.aia (11.4 KB)

Thanks Anke, the gallery now refreshes when I use the AI Companion. When I compile and use the app directly on the phone, I get the attached runtime error. Could you please suggest the solution for this.

Rename the fileName to "myImage1.jpg" and try again without testing with Companion beforehand.

Thanks Anke, this works !