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.
    EDIT: As i suspected, the permissions are now removed after the nb187 release!

Here is a special version of the extension, that does not show a notification while / after downloading (released on Aug 24, 2021):
DownloadToASD_notifHidden2.aix (7.6 KB)
Note: Use this version of the extension only if you don't want a notification while / after downloading.

10 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!

2 Likes
  1. Will it download drive file
  2. Will it increase storage or not
  3. Once downloaded can I delete using @taifun file extension

Yeah, but why don't you just try?

Sorry not enough time can someone test never think bad

@Anke Cool Download to ASD extension. What type of apps would require this?

@Anke Edit: What type of app would need this extension to download to the app's directory?
I'm new to this, so I'm just asking.

What do you mean by that?

How can I retrieve the file I downloaded to put it in a videoplayer?

I saw that but it gives error 701 in my code


I have those.I skipped the global count because player will download it only once

I believe you are missing a / in your code

1 Like

Thanks for this wonderful extension.
One question:
every time when downloadcompleted, this message will show up, telling me some file is downloaded.
Howe to disable this?

I didn't get that message as you can see here.
(please translate the message)

OK no problem. Maybe its only on some devices.

or is it because this?