VOOZH about

URL: https://www.geeksforgeeks.org/android/how-to-implement-in-app-update-prompt-in-android/

⇱ How to implement in-app update prompt in Android? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to implement in-app update prompt in Android?

Last Updated : 23 Jul, 2025

Normally to check for an app's update, a user need to open play store, navigate to the app's page and click on check for updates. But, what if we can notify the user as soon as there's an update release for the app on the app's screen itself. That's where In-App Updates comes into motion. In-app updates is a Google Play Core libraries feature that prompts the user to update their app immediately when the user opens it.

👁 Flexible-updates-and-Immediate-updates

Types of In-App Updates:

There are two types of updates flows:

  1. Flexible Updates: The user can continue using the app while the update downloads in the background. Once downloaded, the app prompts for a restart.
  2. Immediate Update: A full-screen update prompt forces the user to update before continuing.

Step by Step Implementation

Step 1: Create a new project

To create a new project in the Android Studio, please refer to How to Create/Start a New Project in Android Studio?

Step 2: Add dependencies for in-app updates

Navigate to Gradle Scripts > build.gradle.kts (Module: app) and add the following dependencies under the dependencies{} scope.

dependencies {
...
implementation ("com.google.android.play:app-update:2.1.0")
implementation ("com.google.android.play:app-update-ktx:2.1.0")
}

Step 3: Add view binding support

Navigate to Gradle Scripts > build.gradle.kts (Module: app) and add the following code anywhere under the android{} scope.

android {
...
buildFeatures {
viewBinding = true
}
...
}

Now, select on the Sync prompt on the top-right corner of the code screen.

Step 4: Check for Updates

Navigate to app > java > {package-name} > MainActivity. First, initialize the App Update Manager and Activity Result Launcher

// kotlin
private lateinit var appUpdateManager: AppUpdateManager
private lateinit var activityResultLauncher: ActivityResultLauncher<IntentSenderRequest>

// java
private AppUpdateManager appUpdateManager;
private ActivityResultLauncher<IntentSenderRequest> activityResultLauncher;

Then, create a function to check for app updates and call the function in the overridden onCreate() method.


Step 5: Handle Update Completion

Now, you might have noticed we have registered a listener to out app update manager to listen for update complement. This will help us prompting the user to restart the app in order to finish pending installations.

First, create the listener


Then, create the function for a snackbar prompting to restart the app and finish installation.


Step 6: Resume Pending Updates

Now, override the onResume() method to prompt user for the restart since the app will be temporarily paused due to the update. Also, remember to override the onStop() method to unregister the listener.


Step 7: Working with MainActivity

Here's the entire code for the MainActivity file.


Comment
Article Tags:

Explore