Reputation: 129
Ive been looking for a good example, how to update my own developed application. So, I have an installed apk on my device and when I started it I'd like to check if any updates are exist on my server. If it does, then download from the webserver and install it.
At first I have to check to my server if there are any updates. If it does then download and install it.
Which is the best way for that? And anybody could show me some tutorial or maybe example?
Thanks afurther to your answers
Upvotes: 6
Views: 18865
Reputation: 61
None of the solutions here and on the provided links work with the latest android versions - 8.0 (oreo) and above.
3 steps to follow to build solution for this
Check the installed version against the latest available on local server. Setup a local server for this purpose which provides the json to check metadata and another url to download latest Apk. Dowbload and install to execute only if newer version available.
Once newer version available, step 2 is to download the apk from local server url. Use download manager for this purpose.In my application this part is working on Oreo after settting the downloadmanager request network as wifi. Its not working on Android 10 so far and remains stuck at download pending status.
Install downloaded apk. In new android version you need to use Fileprovider. Without Fileprovider approach it wont work.
Upvotes: 0
Reputation: 5764
Check out this link. It uses a HTTP connection in an async task to download the APK file from an URL. When the download is finished it starts a new intend for showing/installing the APK (see this article).
Upvotes: 4