# FakeAppUpdateManager

Summary:[Ctors](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager#pubctors)\|[Methods](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager#inhmethods)  

# FakeAppUpdateManager

`
public


class
FakeAppUpdateManager
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object.html)`


``


implements

`[AppUpdateManager](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html)`


`

|---|---------------------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | com.google.android.play.core.appupdate.testing.FakeAppUpdateManager |

<br />

*** ** * ** ***

A fake implementation of the[AppUpdateManager](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html).

This implementation is completely self-contained in the library and does not interact with the Play Store. For this reason, no UI is shown and no update is performed on the device. You can use this API to test your[support for in-app updates](https://developer.android.com/guide/app-bundle/in-app-updates), such as initiating update flows, checking download progress, and handling failure scenarios.

Keep in mind, you should use this API for only unit-tests and early development iterations. It is not intended for full stack integration tests, which you can conduct by uploading the latest version of your app to Play and sideloading an older version of your app that supports in-app updates onto your test device.

## Summary

|                                                                                                                                                                                                                            ### Public constructors                                                                                                                                                                                                                            ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[FakeAppUpdateManager](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#FakeAppUpdateManager(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Creates a fake instance of[AppUpdateManager](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html), which you can use for testing. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Task](https://developer.google.com/android/reference/com/google/android/gms/tasks/Task.html)`<`[Void](https://developer.android.com/reference/java/lang/Void.html)`>`                                                | ` `[completeUpdate](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#completeUpdate())`() ` For a flexible update flow, triggers the completion of the update.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                                                                                                                                                                  | ` `[downloadCompletes](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#downloadCompletes())`() ` Simulates the download completing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` void`                                                                                                                                                                                                                  | ` `[downloadFails](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#downloadFails())`() ` Simulates a download failure.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` void`                                                                                                                                                                                                                  | ` `[downloadStarts](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#downloadStarts())`() ` Simulates the download starting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` `[Task](https://developer.google.com/android/reference/com/google/android/gms/tasks/Task.html)`<`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)`>` | ` `[getAppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#getAppUpdateInfo())`() ` Requests the update availability for the current app, an intent to start an update flow, and, if applicable, the state of updates currently in progress.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` `[Integer](https://developer.android.com/reference/java/lang/Integer.html)                                                                                                                                             | ` `[getTypeForUpdateInProgress](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#getTypeForUpdateInProgress())`() ` Returns the type of update that's currently in progress or null, if no update is in progress.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` void`                                                                                                                                                                                                                  | ` `[installCompletes](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#installCompletes())`() ` Simulates the download completing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` void`                                                                                                                                                                                                                  | ` `[installFails](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#installFails())`() ` Simulates an update install failure.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` boolean`                                                                                                                                                                                                               | ` `[isConfirmationDialogVisible](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#isConfirmationDialogVisible())`() ` Returns whether the user confirmation dialog of the flexible update is visible to the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` boolean`                                                                                                                                                                                                               | ` `[isImmediateFlowVisible](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#isImmediateFlowVisible())`() ` Returns whether the user confirmation screen of the immediate update is visible to the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` boolean`                                                                                                                                                                                                               | ` `[isInstallSplashScreenVisible](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#isInstallSplashScreenVisible())`() ` Returns whether the splash screen is visible to the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` void`                                                                                                                                                                                                                  | ` `[registerListener](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#registerListener(com.google.android.play.core.install.InstallStateUpdatedListener))`(`[InstallStateUpdatedListener](https://developer.android.com/reference/com/google/android/play/core/install/InstallStateUpdatedListener.html)` listener) ` Registers a listener for this app that receives state changes for self-update operations.                                                                                                                                                                                                                                                                                          |
| ` void`                                                                                                                                                                                                                  | ` `[setBytesDownloaded](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#setBytesDownloaded(long))`(long bytesDownloaded) ` Simulates progress of the download by setting the number of bytes already downloaded.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` void`                                                                                                                                                                                                                  | ` `[setClientVersionStalenessDays](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#setClientVersionStalenessDays(java.lang.Integer))`(`[Integer](https://developer.android.com/reference/java/lang/Integer.html)` clientVersionStaleness) ` Sets the staleness of the version installed on user's device.                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                                                                                                                                  | ` `[setInstallErrorCode](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#setInstallErrorCode(int))`(int installErrorCode) ` Sets an error code which is returned by certain update flow API calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                                                                                                                                                                  | ` `[setTotalBytesToDownload](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#setTotalBytesToDownload(long))`(long totalBytesToDownload) ` Sets the size of an available update in bytes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` void`                                                                                                                                                                                                                  | ` `[setUpdateAvailable](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#setUpdateAvailable(int,%20int))`(int availableVersionCode, int appUpdateType) ` Declares that an update is available but only`appUpdateType`is allowed to execute it.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                                                                                                                                                                  | ` `[setUpdateAvailable](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#setUpdateAvailable(int))`(int availableVersionCode) ` Declares that an update is available and both the flexible and immediate flow can be used to execute it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` void`                                                                                                                                                                                                                  | ` `[setUpdateNotAvailable](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#setUpdateNotAvailable())`() ` Declares that no updates are available.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` void`                                                                                                                                                                                                                  | ` `[setUpdatePriority](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#setUpdatePriority(int))`(int updatePriority) ` Sets the priority of the available update.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` boolean`                                                                                                                                                                                                               | ` `[startUpdateFlowForResult](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20int,%20com.google.android.play.core.common.IntentSenderForResultStarter,%20int))`(`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)` appUpdateInfo, int appUpdateType, IntentSenderForResultStarter starter, int requestCode) ` Starts the desired update flow.                                                                                                                                                                                                         |
| ` boolean`                                                                                                                                                                                                               | ` `[startUpdateFlowForResult](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20int,%20android.app.Activity,%20int))`(`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)` appUpdateInfo, int appUpdateType, `[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, int requestCode) ` Starts the desired update flow.                                                                                                                                                                                                 |
| ` boolean`                                                                                                                                                                                                               | ` `[startUpdateFlowForResult](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20androidx.activity.result.ActivityResultLauncher<androidx.activity.result.IntentSenderRequest>,%20com.google.android.play.core.appupdate.AppUpdateOptions))`(`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)` appUpdateInfo, ActivityResultLauncher<IntentSenderRequest> activityResultLauncher, `[AppUpdateOptions](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateOptions.html)` options) ` Starts the desired update flow. |
| ` void`                                                                                                                                                                                                                  | ` `[unregisterListener](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#unregisterListener(com.google.android.play.core.install.InstallStateUpdatedListener))`(`[InstallStateUpdatedListener](https://developer.android.com/reference/com/google/android/play/core/install/InstallStateUpdatedListener.html)` listener) ` Unregisters a listener you previously registered using[registerListener(InstallStateUpdatedListener)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#registerListener(com.google.android.play.core.install.InstallStateUpdatedListener)).                                                                                |
| ` void`                                                                                                                                                                                                                  | ` `[userAcceptsUpdate](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#userAcceptsUpdate())`() ` Simulates that a user has accepted an update from the update confirmation dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                                                                                                                                                                  | ` `[userCancelsDownload](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#userCancelsDownload())`() ` Simulates the user canceling the download via the Play UI.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` void`                                                                                                                                                                                                                  | ` `[userRejectsUpdate](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#userRejectsUpdate())`() ` Simulates that a user has declined an update from the update confirmation dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||
| From interface` `[com.google.android.play.core.appupdate.AppUpdateManager](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html)` ` |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[Task](https://developer.google.com/android/reference/com/google/android/gms/tasks/Task.html)`<`[Void](https://developer.android.com/reference/java/lang/Void.html)`>`                                                | ` `[completeUpdate](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#completeUpdate())`() ` For a flexible update flow, triggers the completion of the update.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` abstract `[Task](https://developer.google.com/android/reference/com/google/android/gms/tasks/Task.html)`<`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)`>` | ` `[getAppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#getAppUpdateInfo())`() ` Requests the update availability for the current app, an intent to start an update flow, and, if applicable, the state of updates currently in progress.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | | ` abstract void`                                                                                                                                                                                                                  | ` `[registerListener](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#registerListener(com.google.android.play.core.install.InstallStateUpdatedListener))`(`[InstallStateUpdatedListener](https://developer.android.com/reference/com/google/android/play/core/install/InstallStateUpdatedListener.html)` listener) ` Registers a listener for this app that receives state changes for self-update operations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | | ` abstract `[Task](https://developer.google.com/android/reference/com/google/android/gms/tasks/Task.html)`<`[Integer](https://developer.android.com/reference/java/lang/Integer.html)`>`                                          | ` `[startUpdateFlow](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlow(com.google.android.play.core.appupdate.AppUpdateInfo,%20android.app.Activity,%20com.google.android.play.core.appupdate.AppUpdateOptions))`(`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)` appUpdateInfo, `[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, `[AppUpdateOptions](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateOptions.html)` options) ` Starts the desired update flow asynchronously.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | ` abstract boolean`                                                                                                                                                                                                               | ` `[startUpdateFlowForResult](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20androidx.activity.result.ActivityResultLauncher<androidx.activity.result.IntentSenderRequest>,%20com.google.android.play.core.appupdate.AppUpdateOptions))`(`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)` appUpdateInfo, ActivityResultLauncher<IntentSenderRequest> activityResultLauncher, `[AppUpdateOptions](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateOptions.html)` options) ` Starts the desired update flow.                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | ` abstract boolean`                                                                                                                                                                                                               | ` `[startUpdateFlowForResult](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20int,%20com.google.android.play.core.common.IntentSenderForResultStarter,%20int))`(`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)` appUpdateInfo, int appUpdateType, IntentSenderForResultStarter starter, int requestCode) ` *This method is deprecated. This API has been deprecated in favor of startUpdateFlowForResult(AppUpdateInfo, IntentSenderForResultStarter, AppUpdateOptions, int). Please use[AppUpdateOptions](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateOptions.html)to specify[AppUpdateType](https://developer.android.com/reference/com/google/android/play/core/install/model/AppUpdateType.html).*                                                                                                                                                                                                                                                                     | | ` abstract boolean`                                                                                                                                                                                                               | ` `[startUpdateFlowForResult](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20android.app.Activity,%20com.google.android.play.core.appupdate.AppUpdateOptions,%20int))`(`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)` appUpdateInfo, `[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, `[AppUpdateOptions](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateOptions.html)` options, int requestCode) ` Starts the desired update flow.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` abstract boolean`                                                                                                                                                                                                               | ` `[startUpdateFlowForResult](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20int,%20android.app.Activity,%20int))`(`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)` appUpdateInfo, int appUpdateType, `[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, int requestCode) ` *This method is deprecated. This API has been deprecated in favor of[startUpdateFlowForResult(AppUpdateInfo, Activity, AppUpdateOptions, int)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20android.app.Activity,%20com.google.android.play.core.appupdate.AppUpdateOptions,%20int)). Please use[AppUpdateOptions](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateOptions.html)to specify[AppUpdateType](https://developer.android.com/reference/com/google/android/play/core/install/model/AppUpdateType.html).* | | ` abstract boolean`                                                                                                                                                                                                               | ` `[startUpdateFlowForResult](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20com.google.android.play.core.common.IntentSenderForResultStarter,%20com.google.android.play.core.appupdate.AppUpdateOptions,%20int))`(`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)` appUpdateInfo, IntentSenderForResultStarter starter, `[AppUpdateOptions](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateOptions.html)` options, int requestCode) ` Starts the desired update flow.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | ` abstract void`                                                                                                                                                                                                                  | ` `[unregisterListener](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#unregisterListener(com.google.android.play.core.install.InstallStateUpdatedListener))`(`[InstallStateUpdatedListener](https://developer.android.com/reference/com/google/android/play/core/install/InstallStateUpdatedListener.html)` listener) ` Unregisters a listener you previously registered using[registerListener(InstallStateUpdatedListener)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#registerListener(com.google.android.play.core.install.InstallStateUpdatedListener)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | ||

## Public constructors

### FakeAppUpdateManager

```
public FakeAppUpdateManager (Context context)
```

Creates a fake instance of[AppUpdateManager](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html), which you can use for testing.

**Note:**This class should be used as a test-scoped singleton in unit tests and as an app-wide singleton during app development.

<br />

|         Parameters          ||
|-----------|------------------|
| `context` | `Context` <br /> |

## Public methods

### completeUpdate

```
public Task<Void> completeUpdate ()
```

For a flexible update flow, triggers the completion of the update.

You should call this method to complete an update that has already been started via[startUpdateFlowForResult(AppUpdateInfo, Activity, AppUpdateOptions, int)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20android.app.Activity,%20com.google.android.play.core.appupdate.AppUpdateOptions,%20int))and is in the[InstallStatus.DOWNLOADED](https://developer.android.com/reference/com/google/android/play/core/install/model/InstallStatus.html#DOWNLOADED)state.

<br />

|                                                                                    Returns                                                                                     ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [Task](https://developer.google.com/android/reference/com/google/android/gms/tasks/Task.html)`<`[Void](https://developer.android.com/reference/java/lang/Void.html)`>` | <br /> |

### downloadCompletes

```
public void downloadCompletes ()
```

Simulates the download completing.

This method call works only after[downloadStarts()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#downloadStarts()).

<br />

### downloadFails

```
public void downloadFails ()
```

Simulates a download failure.

This method call works only if the download of an update is pending or downloading.

<br />

### downloadStarts

```
public void downloadStarts ()
```

Simulates the download starting.

This method call works only after calling[userAcceptsUpdate()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#userAcceptsUpdate()).

<br />

### getAppUpdateInfo

```
public Task<AppUpdateInfo> getAppUpdateInfo ()
```

Requests the update availability for the current app, an intent to start an update flow, and, if applicable, the state of updates currently in progress.

To learn more, read[Check for update availability](https://developer.android.com/guide/app-bundle/in-app-updates).

<br />

|                                                                                                            Returns                                                                                                            ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [Task](https://developer.google.com/android/reference/com/google/android/gms/tasks/Task.html)`<`[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)`>` | <br /> |

### getTypeForUpdateInProgress

```
public Integer getTypeForUpdateInProgress ()
```

Returns the type of update that's currently in progress or null, if no update is in progress.

<br />

|                                      Returns                                      ||
|---------------------------------------------------------------------------|--------|
| [Integer](https://developer.android.com/reference/java/lang/Integer.html) | <br /> |

### installCompletes

```
public void installCompletes ()
```

Simulates the download completing.

This method call works only after[completeUpdate()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#completeUpdate())has been triggered by the application.

<br />

### installFails

```
public void installFails ()
```

Simulates an update install failure.

This method call works only if the update is already installing (after a call to[completeUpdate()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#completeUpdate())).

<br />

### isConfirmationDialogVisible

```
public boolean isConfirmationDialogVisible ()
```

Returns whether the user confirmation dialog of the flexible update is visible to the user.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isImmediateFlowVisible

```
public boolean isImmediateFlowVisible ()
```

Returns whether the user confirmation screen of the immediate update is visible to the user.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isInstallSplashScreenVisible

```
public boolean isInstallSplashScreenVisible ()
```

Returns whether the splash screen is visible to the user. This occurs during update completion. In the real implementation, your app is reloaded with the new version.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### registerListener

```
public void registerListener (InstallStateUpdatedListener listener)
```

Registers a listener for this app that receives state changes for self-update operations. Typically, you need to register a listener for only*Flexible* updates, and listeners should be unregistered using[unregisterListener(InstallStateUpdatedListener)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#unregisterListener(com.google.android.play.core.install.InstallStateUpdatedListener))when you no longer need them.

To learn more, read[Handle a flexible update](https://d.android.com/guide/app-bundle/in-app-updates#flexible_flow).

<br />

|                                     Parameters                                      ||
|------------|-------------------------------------------------------------------------|
| `listener` | `InstallStateUpdatedListener`: the listener you want to register <br /> |

### setBytesDownloaded

```
public void setBytesDownloaded (long bytesDownloaded)
```

Simulates progress of the download by setting the number of bytes already downloaded.

This method call works only after calling[setTotalBytesToDownload(long)](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#setTotalBytesToDownload(long)).

<br />

|            Parameters            ||
|-------------------|---------------|
| `bytesDownloaded` | `long` <br /> |

### setClientVersionStalenessDays

```
public void setClientVersionStalenessDays (Integer clientVersionStaleness)
```

Sets the staleness of the version installed on user's device.

This method call only has effect if update is available.

<br />

|                                              Parameters                                               ||
|--------------------------|-----------------------------------------------------------------------------|
| `clientVersionStaleness` | `Integer`: the number of days client has known about the fake update <br /> |

### setInstallErrorCode

```
public void setInstallErrorCode (int installErrorCode)
```

Sets an error code which is returned by certain update flow API calls.

The error code is returned calls to[getAppUpdateInfo()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#getAppUpdateInfo())and[completeUpdate()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#completeUpdate()). However, the error code might not be honored if a more severe workflow error occurs, such as if[completeUpdate()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#completeUpdate())you call before an update is downloaded.

The error code is persistent. So, you need reset the value by calling the same method and passing[InstallErrorCode.NO_ERROR](https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode.html#NO_ERROR).

<br />

|                              Parameters                               ||
|--------------------|---------------------------------------------------|
| `installErrorCode` | `int`: the error code you want to simulate <br /> |

### setTotalBytesToDownload

```
public void setTotalBytesToDownload (long totalBytesToDownload)
```

Sets the size of an available update in bytes.

This method call works only after calling[downloadStarts()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#downloadStarts()).

<br />

|                                Parameters                                ||
|------------------------|--------------------------------------------------|
| `totalBytesToDownload` | `long`: total size of the update in bytes <br /> |

### setUpdateAvailable

```
public void setUpdateAvailable (int availableVersionCode, 
                int appUpdateType)
```

Declares that an update is available but only`appUpdateType`is allowed to execute it.

<br />

|                                Parameters                                 ||
|------------------------|---------------------------------------------------|
| `availableVersionCode` | `int`: the version code of the fake update <br /> |
| `appUpdateType`        | `int` <br />                                      |

### setUpdateAvailable

```
public void setUpdateAvailable (int availableVersionCode)
```

Declares that an update is available and both the flexible and immediate flow can be used to execute it.

<br />

|                                Parameters                                 ||
|------------------------|---------------------------------------------------|
| `availableVersionCode` | `int`: the version code of the fake update <br /> |

### setUpdateNotAvailable

```
public void setUpdateNotAvailable ()
```

Declares that no updates are available.

<br />

### setUpdatePriority

```
public void setUpdatePriority (int updatePriority)
```

Sets the priority of the available update.

This method call only has effect if update is available.

<br />

|                            Parameters                            ||
|------------------|------------------------------------------------|
| `updatePriority` | `int`: priority of the available update <br /> |

### startUpdateFlowForResult

```
public boolean startUpdateFlowForResult (AppUpdateInfo appUpdateInfo, 
                int appUpdateType, 
                IntentSenderForResultStarter starter, 
                int requestCode)
```

Starts the desired update flow.

This method should be called if you are starting the flow from a Component different from an`Activity`and you don't want to receive the`onActivityResult`call on the Activity.

This is identical to calling[startUpdateFlowForResult(AppUpdateInfo, IntentSenderForResultStarter, AppUpdateOptions, int)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20com.google.android.play.core.common.IntentSenderForResultStarter,%20com.google.android.play.core.appupdate.AppUpdateOptions,%20int)), with the[AppUpdateOptions.defaultOptions(int)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateOptions.html#defaultOptions(int))for the requested update flow. See its documentation for further information.

For a list of possible result values and parameter documentation, see[startUpdateFlowForResult(AppUpdateInfo, IntentSenderForResultStarter, AppUpdateOptions, int)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20com.google.android.play.core.common.IntentSenderForResultStarter,%20com.google.android.play.core.appupdate.AppUpdateOptions,%20int)).

<br />

|                       Parameters                       ||
|-----------------|---------------------------------------|
| `appUpdateInfo` | `AppUpdateInfo` <br />                |
| `appUpdateType` | `int` <br />                          |
| `starter`       | `IntentSenderForResultStarter` <br /> |
| `requestCode`   | `int` <br />                          |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### startUpdateFlowForResult

```
public boolean startUpdateFlowForResult (AppUpdateInfo appUpdateInfo, 
                int appUpdateType, 
                Activity activity, 
                int requestCode)
```

Starts the desired update flow.

Starts a flow of the provided[AppUpdateType](https://developer.android.com/reference/com/google/android/play/core/install/model/AppUpdateType.html).

This is identical to calling[startUpdateFlowForResult(AppUpdateInfo, Activity, AppUpdateOptions, int)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20android.app.Activity,%20com.google.android.play.core.appupdate.AppUpdateOptions,%20int)), with the[AppUpdateOptions.defaultOptions(int)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateOptions.html#defaultOptions(int))for the requested update flow. See its documentation for further information.

For a list of possible result values and parameter documentation, see[startUpdateFlowForResult(AppUpdateInfo, Activity, AppUpdateOptions, int)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20android.app.Activity,%20com.google.android.play.core.appupdate.AppUpdateOptions,%20int)).

<br />

|               Parameters                ||
|-----------------|------------------------|
| `appUpdateInfo` | `AppUpdateInfo` <br /> |
| `appUpdateType` | `int` <br />           |
| `activity`      | `Activity` <br />      |
| `requestCode`   | `int` <br />           |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### startUpdateFlowForResult

```
public boolean startUpdateFlowForResult (AppUpdateInfo appUpdateInfo, 
                ActivityResultLauncher<IntentSenderRequest> activityResultLauncher, 
                AppUpdateOptions options)
```

Starts the desired update flow.

This API uses the ActivityResultLauncher provided by Jetpack components to launch the update flow for result.

Starts a flow with the provided options, including the flow type. Requires an[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html), which you can receive from[getAppUpdateInfo()](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#getAppUpdateInfo()). This method can only start update flow types that are allowed according to[AppUpdateInfo.isUpdateTypeAllowed(AppUpdateOptions)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html#isUpdateTypeAllowed(com.google.android.play.core.appupdate.AppUpdateOptions)).

Each[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)instance can be used only in a single call to this method. If you need to call it multiple times - for instance, when retrying to start a flow in case of failure - you need to get a fresh[AppUpdateInfo](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html)from[getAppUpdateInfo()](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#getAppUpdateInfo()).

For a list of possible result values, see[startUpdateFlowForResult(AppUpdateInfo, Activity, AppUpdateOptions, int)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#startUpdateFlowForResult(com.google.android.play.core.appupdate.AppUpdateInfo,%20android.app.Activity,%20com.google.android.play.core.appupdate.AppUpdateOptions,%20int)).

<br />

|                                                                                                                              Parameters                                                                                                                              ||
|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `appUpdateInfo`          | `AppUpdateInfo`: an intent you use to start an update. You get this using[getAppUpdateInfo()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#getAppUpdateInfo()). <br /> |
| `activityResultLauncher` | `ActivityResultLauncher`: An ActivityResultLauncher to launch the update flow. <br />                                                                                                                                                      |
| `options`                | `AppUpdateOptions`: the update options, including the type of flow. <br />                                                                                                                                                                 |

|                           Returns                           ||
|-----------|--------------------------------------------------|
| `boolean` | whether the requested update has started. <br /> |

### unregisterListener

```
public void unregisterListener (InstallStateUpdatedListener listener)
```

Unregisters a listener you previously registered using[registerListener(InstallStateUpdatedListener)](https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateManager.html#registerListener(com.google.android.play.core.install.InstallStateUpdatedListener)).

To learn more, read[Handle a flexible update](https://d.android.com/guide/app-bundle/in-app-updates#flexible_flow).

<br />

|                                      Parameters                                       ||
|------------|---------------------------------------------------------------------------|
| `listener` | `InstallStateUpdatedListener`: the listener you want to unregister <br /> |

### userAcceptsUpdate

```
public void userAcceptsUpdate ()
```

Simulates that a user has accepted an update from the update confirmation dialog. The download is enqueued in[InstallStatus.PENDING](https://developer.android.com/reference/com/google/android/play/core/install/model/InstallStatus.html#PENDING)status.

This method call works only if[isConfirmationDialogVisible()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#isConfirmationDialogVisible())or[isImmediateFlowVisible()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#isImmediateFlowVisible())is true.

In the real implementation, a[Activity.RESULT_OK](https://developer.android.com/reference/android/app/Activity.html#RESULT_OK)is also received by the calling activity's[ERROR(/android.app.Activity#onActivityResult)](https://developer.android.com/).

<br />

### userCancelsDownload

```
public void userCancelsDownload ()
```

Simulates the user canceling the download via the Play UI.

This method call works only if the download of an update is pending or downloading.

<br />

### userRejectsUpdate

```
public void userRejectsUpdate ()
```

Simulates that a user has declined an update from the update confirmation dialog.

This method call works only if[isConfirmationDialogVisible()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#isConfirmationDialogVisible())or[isImmediateFlowVisible()](https://developer.android.com/reference/com/google/android/play/core/appupdate/testing/FakeAppUpdateManager.html#isImmediateFlowVisible())is true.

In the real implementation, a[Activity.RESULT_CANCELED](https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED)is also received by the calling activity's[ERROR(/android.app.Activity#onActivityResult)](https://developer.android.com/).

<br />