Cache refresh with ai2?

Thank, you very much, but it looks, that it doesn‘t work.
Where should I plug the block?

You need to provide an accurate file path, what you show will be a filename that does not exist (clock1.now)

What I am doing:

But the GalleryRefreh should be plugged in somwhere. Don‘t you think?

yes of course
for example set label1.text to ...

also a few milliseconds later, Clock.Now gives you another time in milliseconds and as you currently doing it your file will not be found therefore...

store the toFilename in a variable and use that filename to refresh

Taifun,

1 Like

Thank you, Taifun.I tried this:


„This block can not be in a definition‘ ?
I get crazy

but it has no effect. The filename is anyway a timestamp but no refresh of the gallery happens.

Initialize filename as a blank string, then set its value to the filename inside the AfterScreenshot event.
Or, use a local variable inside the AfterScreenshot event.

Thank you very much, to all rhe nice and friendly guys here.

I hope, I do not hurt your nerves too much.

I want to describe again:

The filename is absolutely OK. The Screenshot is taken perfectly and is stored in the right folder. I can see it there (DCIM/Camera). But I CAN NOT SEE IT IN THE GALLERY.
After booting my Device, I can see it there.

Maybe GalleryRefresh doesn‘t work, or I use it the wrong way.

Please help

Thanx

Emanuel (Austria/Europe)

Here is my complete .aia
(please rename Bike.aia into Bike.aia.zip (couldn‘t upload it otherwise ;-))
Bike.aia (246.7 KB)

  1. Store the "to filename" in a variable
  2. Move the file
  3. Use gallery refresh method with the stored "to filename"

Taifun

Thank you, Taifun

I did:

nothing changed.
I made an app with only ‚Screenshot‘ and GalleryRefresh and also nothing worked.
I am crying.

did you see the red error x?
move the set filename to after screen shot event.

You already got that advice earlier

Taifun

1 Like

It would be a good idea to learn some basics..

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps
How to do a lot of basic things with App Inventor are described here: How do you...? .

Also do the tutorials Our Tutorials! to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Thank you Taifun and all the other guys. I think, I made everything you said.

local variable. initialzed first and after screenshot.
Nothing changed. Again:

The Foto with the correct name is placed in the right folder: DCIM/Camera
BUT: It can not be seen in the Gallery.
(only after restarting the phone)

I can‘t stop crying meanwhile.

How are you then viewing the gallery through your app ? Or are you not ?

This is working for me using companion on Android 15

1 Like

Thank you very much TIMAI2.

No, I want to see the image in the regular GALLERY-App.

Hello, I am getting closer…

But I don‘t know, how to manage this ;-(

If you are testing on an Android device with version less than 10 (or higher) you will need to request WRITE_EXTERNAL_STORAGE instead ?


1m

S o l u t i o n :slight_smile:

After two weeks of research:

Look at the path!

In my case:

/storage/emulated/0/DCIM/Camera/IMG_……

was Okay

DCIM/Camera/IMG_

was too short (too less). It was okay for placing the pic in the right folder, but not enough to refreh the gallery-App.

Another important thing is the version. I managed it this way:

(I hope it works :wink: couldn‘t test properly soon)

good luck!

Emanuel