Intent for Installing .apk via Web URL

67 views Asked by At

From an Android app, I like to install an apk file from a web server. This apk file contains an update for the app.

All tutorials do this in two steps:

1 Download the file and save it to the phone's sd card memory. 2 Create a new Intent(Intent.ACTION_VIEW) and run the method setDataAndType(Uri.fromFile(new File(".... of this intent.

However, since Android Nougat, you get into trouble with permission to access the SD card memory. There are (complicated) solutions for this problem.

My question: is there a way to create an Intent, which gets a web URL as source for the apk file. Something like intent.setDataAndType(new URL("http://....")

This is easy for the programmer and it provides as clear interface from the program to the Android system

1

There are 1 answers

0
CommonsWare On

is there a way to create an Intent, which gets a web URL as source for the apk file. Something like intent.setDataAndType(new URL("http://....")

Not as part of standard Android. The app installer knows about the file scheme, and on Android 7.0+ it knows about the content scheme. It does not know about the http scheme.

All tutorials do this in two steps... Download the file and save it to the phone's sd card memory.

Few tutorials do that. Most download the file to external storage, which is not the same as removable storage. On Android 7.0+, you also have the option of downloading to internal storage and using FileProvider (or the equivalent) to make it available via a content Uri.