Is there a way to trigger a final procedure as an app exits?
One of my apps generates user input via image picker, and while I know it only stores 10 selections it still adds clutter to gallery. I would like to delete the picked images through taifun file on app close.
I know how to delete stuff, just not quite sure how to utilize closing the app to trigger the procedure.
The problem in my specific case is this is more of a PWA, it uses webview on a specific site, there are no buttons to trigger the event. Uploads are permitted which is what image picker is used for and unfortunately there is no "on upload complete" block that I could use either.
Anke gave me an idea though. I use the back button to "go back" to the starting website. I could probably include an if then statement like if current url = starting url on back press, then call taifun filelist and for each item in the file list call taifun delete. Then close.
No idea what was going on before, I removed the "close application" to test the delete to ensure it wasn't a race condition and it still wasn't working. It had to either be something to do with the path, or some nuance with the delete block since this is essentially the same thing I had before, just more roundabout.
I ended up using the attached in the delete procedure, which does work. Get file list > Remove file path (except filename) and rewrite to list > Get revised list > Call delete for each item and add back in the file path.
My compiled apk works fine with what I posted above....Not sure what you are suggesting, as the issue with my other attempts can be narrowed down to either a block issue or filepath issue. Given the working solution only strips the path and reintroduces it later....and works.
Your first "Try this" is the exact thing I already posted..and said didn't work. Even though it should.
The native image picker in ai2 copies the selected image when called/selected to /Pictures/_app_inventor_image_picker/
its literally in the ai2 docs. I hate it.
Of course you don't see read/write permission. I grant it on screen initialize which obviously I didnt post because it isn't relevant. My total blocks are huge. If you haven't gathered, I do ok in ai2.
Yes I could have used async, but this job isn't that big.
Ummm....it's an inherent property of image picker.
Here is the literal documentation on it. Try it yourself.
ImagePicker
A special-purpose button. When the user taps an ImagePicker , the device’s image gallery appears, and the user can choose an image. After an image is picked, it is saved, and the Selection property will be the name of the file where the image is stored. In order to not fill up storage, a maximum of 10 images will be stored. Picking more images will delete previous images, in order from oldest to newest.