Download an APK to App-Specific Directory (ASD) and install it without permissions

Here is an extension to install an APK from external storage, especially from ASD, which doesn’t require WRITE_EXTERNAL_STORAGE permission.

This should work on all Android versions, especially on Android 9 / 10 and even when the app (Kodular) targets API 29 (targetSdkVersion=29).

de.bodymindpower.installAPK.aix (7.3 KB)
Note: do NOT use this version anymore, use the new version below!

So check this, especially on your Android 10 devices …

New version
(→ packageName changed → download method added):

I added a Download method (thanks to @vknow360 for support!) with that you can download an APK (or whatever file you like) to the App-Specific Directory (ASD) and install it (without WRITE / READ permissions):
de.bodymindpower.InstallAPK.aix (9.0 KB)

grafik

16 Likes

can it install app without copying apk to specific directory?

Yes of course, but you have to grant WRITE permission.

1 Like

I simplified my example blocks a bit (without using TaifunFile ext):

  • download the APK from Google Drive to the /Download (default) folder and copy it to ASD
  • install AKP from ASD

Of course you need the WRITE permission for this, since the download component always downloads to the standard folder (/storage/emulated/0/Download).

To avoid this, you need to use an extension that also allows you to download a file to a specific folder. I only know that the Download extension from our beloved grafik can do that. Maybe someone has a better suggestion.

1 Like

That is not true.
You can change download location using Save File As property.

No, the file is always in the /Download (sub)folder:

Seems like Kodular uses preset dir.
Download Manager’s documentation says that file will be saved in dir specified using setDestinationInExternalPublicDir method so you can save file in external storage in any dir.
Staff can clarify our doubts.

There is no doubt about it, I have tested it extensively.
However, my suggestion for you would be that you create a small flexible download extension. :wink:

Today i created toipic on it but not got reply…

2 Likes

thank you for your contribution…
does the extension also work in the companion app as well as in App Inventor?
and if you like to follow the naming conventions, then please start the extension name with a capital letter… InstallApk or InstallAPK would be the correct name according to the conventions…

what about using the web component?
see also How to download a file and save it on your device

Taifun

3 Likes

How about that?

I tested with disabling the Storage permission from App Settings, and it is saving to application specific directory.

Example file: dummy.pdf

I also used this extension too:

P.S: Just saw that Taifun recommended the Web component :sweat_smile:

3 Likes

Thanks for the extension… was looking for something like this.

Awesome extension. BTW do we need to manually ask for permissions or the extension asks itself.

It does not work with the Web component because the APK file is corrupted with your procedure after downloading.

I found a way to do it with the Web component only. But in this case you must ask for WRITE permission, because the Web component enforces that, even when downloading to an ASD (shouldn’t be like this!).

See here (works with Companion, of course without asking for WRITE perm.):
installAPK2.aia (41.4 KB)

As I said, we need an extension to flexibly download files to the external storage, especially to the ASD without having to request WRITE permission .

1 Like

That depends on how you use the extension. If you use the Download component, the permission will be requested automatically. If you put the APK in the assets (and copy it to ASD), no permission is required at all.

2 Likes

See here:

1 Like

Here is an APK for testing with 2 methods: installAPK.apk (5.1 MB)

  1. download via extension to ASD (no WRITE permission)
  2. download via Web component to ASD (needs WRITE perm.)

You can set your own download URL and apkName (e.g.: myApp.apk).

Blocks

1 Like

Here is an new version of the extension.
I added a Download method (thanks to @vknow360 for support!) with that you can download an APK (or whatever file you like) to the App-Specific Directory (ASD) and install it (without WRITE / READ permissions):
de.bodymindpower.InstallAPK.aix (9.0 KB)

I also followed the naming conventions, which @Taifun pointed out.

grafik

Example:

1 Like

keep up the good work!

Excellent!

thank you…
please also edit your first post in this thread and replace your old version with the new one…

Taifun

1 Like

Ok, but as I said, it is not an update, but a new version because the package name has been changed.

1 Like