0

I am creating an application that makes the android device essentially run in kiosk mode. (Yes, voluntarily). Part of the application needs to be able to check if a new update of itself is available or not. I've done a few hours of research, but I have many questions. My questions are: 1) I tried to host the file on dropbox, but when the .apk downloads (if the connection doesn't time out) nothing happens. There is not prompt to install/update the app. Why is this? 2) What do I need to include in my code to make the request retry if the request times out? 3) How should I even host the file? Should it be through dropbox, mediafire, or through a personal dedicated server?

As I am just starting within this automatic updating idea, I assume many others are also in my shoes. Thanks Everyone!

Ethan
  • 1,905
  • 2
  • 21
  • 50
  • Is there a reason you cannot host it on Google Play and let it manage any updates? – adelphus May 23 '16 at 21:25
  • Yes it has to remain private and off of the usual marketplace. I also looked into android for work but I would rather go with a free/cheaper option – Ethan May 23 '16 at 21:28
  • it costs $25 dollars to be a google developer for unlimited usage, host the apk on play store, control alpha/beta rollout and general rollout.. any reason why you do not wish to host it on Google Play? – t0mm13b May 23 '16 at 21:44
  • I'm already a google developer... I can't host it on play because that would allow every user to have a google account. Which is not the case for my users of my application. – Ethan May 23 '16 at 22:46
  • could register a singular google account purely for kiosk mode. Add that gmail account associated with that google account to beta testers, deploy app to beta rollout which is private and selective to certain email/google accounts. – t0mm13b May 23 '16 at 23:50
  • That wouldn't work. The application is being placed into a custom ROM as a launcher and then flashed to a device. I wound't be able to add the account before flashing and certainly not after. – Ethan May 23 '16 at 23:53
  • *The application is being placed into a custom ROM as a launcher and then flashed to a device.* You should have mentioned that in the question! You can still add a mechanism for first time boot up to set up that gmail like account provisioning which is a one time thing prior to app launch? – t0mm13b May 23 '16 at 23:59
  • Yeah but that's an extra step that doesn't need to be done. I would much rather have it all within one application and not require my users to have/use their google account – Ethan May 25 '16 at 03:23

2 Answers2

0

If you want to do this manually, there's a bit of work involved, but it is possible. In general you need to:

  • Download the APK (from wherever you want to host it). Save the APK as a file - either in your App's private data area or on external storage. There are questions on SO to help with this.
  • Check if the APK has changed from the current version - a simple SHA-1 hash of the APK file data should work. Compare it against the hash of the APK file currently installed (you can get the installed APK location via ApplicationInfo.sourceDir)
  • If the downloaded APK is stored in your private data area, mark the file as world-readable - this is important because the Android Package Installer will fail to install the App if it cannot access it.
  • If the APK file hash has changed, start an intent to launch the package installer. The user will be prompted to perform the upgrade (there's nothing you can do to install it silently, unless you modify the Android OS).
Community
  • 1
  • 1
adelphus
  • 10,116
  • 5
  • 36
  • 46
  • Where could I host the file that would allow automatic downloading without prompting the user? And by automatic downloading I do not mean the dialog that prompts the user after it has already been downloaded, I mean the first first the is usually found on the hosting website? – Ethan May 23 '16 at 22:44
  • The APK is just a normal zip file - you can host it on any server which allows public internet access. If you're having problems with Dropbox, try some [alternatives](http://www.cloudwards.net/top-10-secure-dropbox-alternatives/) – adelphus May 23 '16 at 22:52
  • But that would force the user to actually click the download button within the website itself right? I need for the update to download and install with the push of a button within my application. Nothing external (chrome, browser, etc) can pop up and prompt the user. I noticed that if I change a download link from dropbox from `https:www.dropbox.com/s/garbage/myfile.apk?dl=0` to `dl=1` the file will automatically start to download on windows, but it doesn't do anything on android. It actually returns a 404. Any ideas why? – Ethan May 23 '16 at 22:59
0

This was actually relatively simple, all I had to do was:

  1. Use JSoup to pull the current version number offline
  2. Compare that number to the current version number
  3. Download the new version from online (hosted by DropBox)
  4. Call an intent to install the newly downloaded .apk And that's it! Simple and effective!
Ethan
  • 1,905
  • 2
  • 21
  • 50