• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Developing android apps that auto-update/install

horatio

Newbie
Hi,

I'm quite new to Android development. I need add auto-update functionality to an application i.e. the application will detect that there is a new version of itself available and then update itself over the web. Are there any resources explaining how to approach this? I've been searching for a while but haven't come across anything concrete yet. Thanks in advance.

H.
 
Maybe I should add some detail. My application will need to be able to

- detect that a new version of itself is available. it will do so by calling out to a RESTful web service.
- The web service will return a list of files required for the application to upgrade itself, based on the current installed version and the new version, with an associated operation for each file i.e. delete, replace, download new
- My android app will then download the files required from an online repository over HTTP

Does this sound possible? Perhaps I need to download an entire APK file for the upgrade rather than the incremental approach that I have described above.

Again, any information, thoughts or suggestion would be greatly appreciated.

Thanks,
H.
 
Thanks Alostpacket!

If the market is the only way to upgrade apps, then is there any means of restricting the applications available to a set of handsets? I don't want to make the application available to everyone but would like to make it available to a set of handsets known in advance, based on the handset IMEI for example.

Horatio.
 
The application that we're developing is for field service engineers and it's quite specialised. We don't want to make it available to the general public. Thanks.
 
So would you have a list of all the IMEIs that were to be allowed access? It may make more sense to allow anybody to access it from the Market, but then restrict it by IMEI at run-time on the hand-set. Depending on the size of the list of IMEIs, it may not be terribly efficient.

Alternatively, you could bypass the Market entirely, and only distribute the apk to the engineers directly.
 
Yeah as 28064212 said you'd probably be best off bypassing the market directly. You could also easily program your app to report it's version number to your server and see if it is out of date and warn your users to upgrade if it is.
 
Thanks for everybody for replying. It seems after all that it is possible to download and install applications. Something like the following works. At least in the emulator! The handset needs to be configured to allow non-market applications to be installed of course.

// Get the binary apk file as data

byte[] data = ** binary apk file **

// write apk to the file system

fos = openFileOutput("uad-RestaurantFinder.apk", Context.MODE_WORLD_READABLE);
fos.write(data);

// create and post an intent to install
Intent intent = new Intent();

String fileAbsPath = "file://" + getFilesDir().getAbsolutePath() + "/" +
"uad-RestaurantFinder.apk";

intent.setAction(android.content.Intent.ACTION_VIEW);

intent.setDataAndType(Uri.parse(fileAbsPath),
"application/vnd.android.package-archive");
startActivity(intent);


 
No. I've tested this and Android will overwrite the existing installation. Application data on the file system in /data/data/package in preserved however which is useful.
 
Oh wow, Sorry, I totally didn't think that was possible. thanks though -- good to know.


Edit: does it still prompt the user with the install dialog?

Edit2: pretty sure it does, if not that would be a huge security hole!
 
Hey Horatio, good post.

I have a similar sort of issue and is something I've been doing with OSGi running on WM devices. OSGi generally allows an application to be broken down into bundles which can be started, stopped and updated etc. on their own with each providing a service to an application. Android also has the notion of services so I wondered if you have had any adventures into developing an application that depends on a number of services that you've implemented yourself which can be updated individually (rather than the whole application)?

Marcus
 
Hi Marcus,

Our application does indeed use services. However, we plan on deploying an entire APK rather than updating the individual services. At the moment, we're not fully sure how we're going to distribute our app. We may use the Android Market on we may use a proprietary solution. The solution that I proposed above does work in the emulator although it may not work on all Android hansets. Is there any reason why you want to update your services individually rather than updating the entire app? The later would be simpler unless your application is very large and you want to do this for efficiency. Sorry that I can't be of any more help.

Cheers,
Horation.
 
Back
Top Bottom