-6

i'm writing my first android application (i'm a newbie in android programming).

I would like to write a code that allows updating without Google Play.

My code have to see if there is a newest version available on my google drive account and advise user. If user click button for updating, my code have to download .apk (in internal storage, if it's possible), install it and delete the .apk file.

I have checked for answer in other question, but i haven't understand what to do. Thanks for you help.

Sorry for my english. I'm italian and i don't speak english very well.

UPDATE: I have found a large part of the code that i need. The only thing that i actually need is ho to compare app's version code to version code of the app hosted on Google Drive.

This is my actual situation:

  1. Compare version with Google Drive's hosted app [THE CODE THAT I NEED]
  2. If the app hosted on Drive is newer than app installed on device, then show a dialog for advise user. [NOT DONE, but i know what to do]
  3. When user allows app to update then start an AsyncTask and download file [DONE]
  4. Install .apk [DONE]
  5. Delete .apk [DONE]

Please help me

Matteo Q.
  • 1
  • 1
  • 4

2 Answers2

2

You can access the version code and version name fields of the android manifest.

context.getPackageManager().getPackageInfo (context.getPackageName(), 0).versionName;
context.getPackageManager().getPackageInfo (context.getPackageName(), 0).versionCode;

Create a web service and API which you call everytime the user opens the application. This service will check the current version or code of the app. If that doesn't match create a dialogue to update the application.

Example of IntentService link or using JSON link.

Vishal Puri
  • 823
  • 8
  • 15
0

It's very easy, follow this steps:

  1. Put latest version code in your website
  2. Create web service to access this code and check with current one
  3. check when user start's app and if new version is available prompt user to update app
  4. Download APK
  5. Run APK for installation.
Adarsh
  • 270
  • 1
  • 3
  • 16