Developing android apps that auto-update/install


Last Updated:

  1. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0
    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.
     

    Advertisement
  2. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0
    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.
     
  3. alostpacket

    alostpacket Over Macho Grande? VIP Member

    Joined:
    Nov 29, 2009
    Messages:
    7,978
    Likes Received:
    3,603
    Not possible, too large a security risk. The market notifies the user when an update is available.
     
    horatio likes this.
  4. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0
    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.
     
  5. 28064212

    28064212 Well-Known Member

    Joined:
    Dec 14, 2009
    Messages:
    245
    Likes Received:
    17
    For what purpose exactly? Is it because your application doesn't run on certain versions of Android? That is fairly easy to do - Versioning Your Applications
     
  6. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0
    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.
     
  7. 28064212

    28064212 Well-Known Member

    Joined:
    Dec 14, 2009
    Messages:
    245
    Likes Received:
    17
    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.
     
  8. alostpacket

    alostpacket Over Macho Grande? VIP Member

    Joined:
    Nov 29, 2009
    Messages:
    7,978
    Likes Received:
    3,603
    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.
     
  9. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0
    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);


     
  10. alostpacket

    alostpacket Over Macho Grande? VIP Member

    Joined:
    Nov 29, 2009
    Messages:
    7,978
    Likes Received:
    3,603
    wouldn't the user then have 2 versions of the app installed?
     
  11. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0
    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.
     
  12. alostpacket

    alostpacket Over Macho Grande? VIP Member

    Joined:
    Nov 29, 2009
    Messages:
    7,978
    Likes Received:
    3,603
    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!
     
  13. codepistol

    codepistol New Member

    Joined:
    Apr 6, 2010
    Messages:
    1
    Likes Received:
    0
    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
     
  14. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0
    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.
     

Share This Page

Loading...