How to Implement the New In-App Update Feature to Your Android App
A quick How-To covering this useful feature
Ever found yourself working all night fixing a bug or adding a groundbreaking feature to your Android app, only to find that just a few of users actually update their apps? Not to worry, Android have now released a new feature called in-app updates, where you can prompt the user to update the app.
Although some users enable background updates when their device is connected to an unmetered connection, other users may need to be reminded to update. In-app updates is a Play Core library feature that introduces a new request flow to prompt active users to update your app.
As an Android developer, it was tiring adding all this code to my apps! So I developed a library which implements the in-app update feature, cutting the whole thing down to five lines of code.
Let’s get started!
Step 1: Add jitpack to your root level
build.gradle, at the end of repositories.
Step 2: Add the dependency to app level
Step 3: Initialize the
UpdateManager in your
onCreate method of the activity.
There are two update modes — Flexible and Immediate:
UpdateManagerConstant.FLEXIBLE) (default) — User can use the app during update download, and installation. Restart needs to be triggered by user.
- Immediate (
UpdateManagerConstant.IMMEDIATE)— User will be blocked until download and installation is finished. Restart is triggered automatically.
Step 4: Call
continueUpdate method in your
onResume method to install waiting updates:
You can find all the above codes in the demo app, check it outif you want to get a head start!
That’s it! Now you have in-app updates in your android app.
Github repository: https://github.com/SanojPunchihewa/InAppUpdater