In-app update

keep your app users up to date on their devices

Vinod Baste
ProAndroidDev

--

Photo by Markus Winkler on Unsplash

Users may test out new features, have access to speed enhancements, and take advantage of bug fixes when they keep your software updated on their devices. Although some users choose to enable background updates when using an unmetered connection, other users might need a reminder to do so.

Active users are prompted to upgrade your app using the in-app updates functionality in Google Play Core libraries.

Devices running Android 5.0 (API level 21) or higher are compatible with the in-app updates feature.

Here are two methods for displaying updates within your app:

Flexible

If the user wants to update the app, a popup window will ask them. Both acceptance and denial are options. If they agree, the update will start downloading behind the scenes. When your update offers a few modest UI tweaks or performance upgrades, utilize this.

Photo on In-app updates

Immediate

The user must update the app in order to use this full-screen UX indefinitely. You can utilize this if you have a crucial update, such as a security patch.

Photo on In-app updates

There are two signals that can start the update:

  • Priority: You specify the update’s importance in each release by providing an integer that ranges from 0 to 5. (5 being the highest priority). In order to update the app, this will start the appropriate update flow (Immediate or Flexible).
  • Staleness: Specifies the amount of time the device has been aware that an update is available. This aids in setting off the appropriate flow. For instance, the Flexible flow would be triggered if the user hadn’t updated the app in the previous 30 days following the release of the update, and the Immediate flow would be triggered if it had been longer than 90 days.

For a better user experience, you may also combine the two signals.

How to implement in-app updates in Android

Add the following dependencies to your module-level build.gradle file.

We’re going to put everything we need in a separate file to make implementation simpler, and then we’re going to call it from the Activity we want to check for updates.

The following code should be pasted into a new file called InAppUpdate.kt

Initialize the InAppUpdate.kt class and add the methods onResume and onActivityResults to your activity (often the MainActivity):

When you use this code and set priority to:

5: Instantly displays Immediate (Recommended for critical updates)
4: Displays Immediacy after 5 days and Flexibility after 3 days.
3: Displays Immediate after 30 days and Flexible after 15 days (Recommended for performance updates)
2: Displays Immediacy after 90 days and Flexibility after 30 days (Recommended for minor updates)
1: Always Shows Flexibility
0: It has no effect on the update flow.

Of course, you are free to modify the code to suit your requirements.

There is no way to set the update’s priority through the Google Play Console; instead, you must use the Google Play Developer API.

Testing

You must upload your app twice to the internal (or alpha or beta) track in order to test your in-app update solution.

Thank you for taking the time to read this article. If you found this post to be useful and interesting, please clap and recommend it.

If I got something wrong, mention it in the comments. I would love to improve.

Connect with me on GitHub and LinkedIn.

--

--