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

With this extension you can download an APK to the ASD (app-specific directory) and install it. This doesn’t require WRITE / READ_EXTERNAL_STORAGE permissions.

However, you can also install an APK from another directory (e.g. the /Download folder) (with READ permissions).

This should work on all Android versions, especially on Android 9, 10, 11.

Update v3 (Oct 25, 2020):
aix removed

Blocks version 3

grafik

Update v4 (Nov 2, 2020):

→ DownloadCompleted event added
→ Create Download directory in ASD
→ Create subfolders in Download dir of ASD

Update v5 (July 30, 2021):
InstallAPK.aix (8.6 KB)
→ Updated → AndroidX

Blocks

Example

Update v6 (April 11, 2022):
de.bodymindpower.installApk.aix (11.2 KB) - EDIT (April 22, 2022):
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
added to Manifest.

With version 5 there seems to be a compiling issue with some special extensions. This has been fixed in version 6. In addition, two new blocks have been added to check if the APK has already been downloaded (exists) and to delete the APK again after downloading. (This version was now created using Rush.)

29 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.

1 Like

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:

1 Like

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:

2 Likes

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