Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art
Auto update /self-updating appBack to Android Cookbook Home | Up to Chapter: Packaging, deploying and selling

Author: Ian Darwin ('idarwin')
In Published Edition? Yes
FormatLanguage: WikiFormat

Auto update /self-updating app


Your app is not in Google Play or another full-featured market but you still want users to get updates when you improve the app.


You can find the last instant your app was updated by judicious use of the package manager.

You can get the last instant the apk on the web server was updated just by sending an HTTP HEAD request.

Compare the two dates and if the web file is newer, open an Intent for the same URI used in the HTTP HEAD, and let the browser handle things from there


If you are hosting your app yourself' as discussed in xxx, you almost certainly want a way to notify users when you update the app. Sending emails doesn't scale well unless you have a scheme for capturing emails with each download. And even then, many users will be too busy. Automating this task makes sense.

The Package Manager knows when it last updated the app, and the web server knows when you last updated the file containing the app. You just have to ask them both and compare the time stamps. If the web file is newer, you have an install candidate; start your UpdateActivity to ask the user if its OK to update. If they say yes, open the browser via a URI back to the web server file. For a slightly better experience, send them to a page about the update. The browser will ultimately prompt the user for the final install. You will need to convince your users that it's OK to accept the somewhat scary warning from installing a no -Play-store app in this way, but they've already set the install from unknown locations to get your app installed in the fist place.

Da codes will be here someday soon.

See Also

Recipe on Installer?