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
Not as part of standard Android. The app installer knows about the
file
scheme, and on Android 7.0+ it knows about thecontent
scheme. It does not know about thehttp
scheme.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 acontent
Uri
.