Extension to download a file to ASD (app-specific directory) without WRITE permission

Here is an extension to download any file (jpg, png, txt, apk, zip, mp3, ...) to the ASD (app-specific directory) without WRITE_EXTERNAL_STORAGE permission.

Version 1 (Oct 31, 2020):
de.bodymindpower.DownloadToASD.aix (8.4 KB)

Blocks

grafik

Version 2 (Nov 1, 2020):
de.bodymindpower.DownloadToASD.aix (9.1 KB)
DownloadCompleted event added:

Example: download an image and display it

The Image component requires READ permission. (→ Shouldn't be like that.)
Therefore you must ask for READ permission (in this case).

Screenshot

Note:

  • Of course you can also use the Web component for this, but this requires WRITE_EXTERNAL_STORAGE permission.

  • I am pretty sure that the READ / WRITE permissions for the ASD will be removed from all relevant components as soon as AI2 targets API 30 (Android 11) → at the end of 2021.
    But maybe @ewpatton could prove me wrong.

8 Likes

Hi @Anke, can you attach the test aia ?

I posted the example blocks and there are only a few blocks. So no problem to do it yourself.

thank you for your contribution

there is only one minor issue... the method DownloadFileToASD is an asynchronous method and usually there should be an event to indicate, that the download has been finished...
therefore you might want to replace your method FileDownloadedToASD by that event
Thank you

Taifun


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

2 Likes

Thank you for the hint.

I'm not sure I can do this without a little help. Maybe I will get a hint from one of the extension experts (from you, @vknow360, @mohamed_tamer ...). As you know, I'm still quite a beginner with extensions / Java. :thinking:

see for example the source code of my headset extension about how to do it... https://puravidaapps.com/headset.php
see especially the Changed event and how it is called from the Broadcast Receiver

Taifun

3 Likes

Done, thank you!

1 Like