In this post, we want to discuss the android code/project for automatically update apps when a new version is published to play store. Before we get started, if you face problem to generate SHA-1 Key, please go through the following article: Generate SHA-1 Keystore Certificate.

Introduction

If you have apps that are hosted on your server and as time passes you make enhancements, fix bugs, etc. then comes the question how can I alert all my app users that a newer version is out there and make it easy for them to download. You can email all your users with the link to the new version, that will be very cumbersome. Well, that process needs to be built right into the app you deploy it for the first time. Here is an example of how to do it is outlined below.

How to Work
  • Create a Web Service which your app can poll whenever the app launches or based on some time limit that can check if there is a new version out there.
  • This Web service should return the latest version of the apk file that is hosted on the Server along with the URI of the application file that has the new version.
  • When your app gets the response from the Web Service, it will parse the JSON and check your app version to the latest version that is available on the server.
  • If your app version is lower than the latest version it will prompt the user to start the download process.
  • Download Manager will be handled the download process of the new app.
  • The download manager will notify your app using the Broadcast Receiver when the download is complete.
  • Upon completion of the latest version of the application file then you can start the activity to install that file.
  • At this point, the user needs to say OKAY, let’s do it.
Java Servlet Web Service to check New Version – CheckAppVersion.java

 

Application Manifest file – AndroidManifest.xml

 

Application Layout file – activity_main.xml

 

IntentService for making Web Service requests – MyWebService.java

 

Application Activity – MainActivity.java

We think you can complete the process to update apps automatically after a new version released. If you face any problem, you can directly contact us.

android code/project for automatically update apps

Leave a Comment

2 Comments