Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Callback

*** ** * ** ***

```
abstract class Callback
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.content.pm.LauncherApps.Callback](https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#) |

Callbacks for package changes to this and related managed profiles.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#Callback()()` <br /> |

| Public methods ||
|---|---|
| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackageAdded(kotlin.String,%20android.os.UserHandle)(packageName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#!)` Indicates that a package was added to the specified profile. |
| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackageChanged(kotlin.String,%20android.os.UserHandle)(packageName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#!)` Indicates that a package was modified in the specified profile. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackageLoadingProgressChanged(kotlin.String,%20android.os.UserHandle,%20kotlin.Float)(packageName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#, progress: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)` Indicates that the loading progress of an installed package has changed. |
| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackageRemoved(kotlin.String,%20android.os.UserHandle)(packageName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#!)` Indicates that a package was removed from the specified profile. |
| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackagesAvailable(kotlin.Array,%20android.os.UserHandle,%20kotlin.Boolean)(packageNames: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>!, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#!, replacing: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Indicates that one or more packages have become available. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackagesSuspended(kotlin.Array,%20android.os.UserHandle)(packageNames: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>!, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#!)` Indicates that one or more packages have been suspended. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackagesSuspended(kotlin.Array,%20android.os.UserHandle,%20android.os.Bundle)(packageNames: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>!, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#!, launcherExtras: https://developer.android.com/reference/kotlin/android/os/Bundle.html#?)` Indicates that one or more packages have been suspended. |
| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackagesUnavailable(kotlin.Array,%20android.os.UserHandle,%20kotlin.Boolean)(packageNames: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>!, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#!, replacing: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Indicates that one or more packages have become unavailable. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackagesUnsuspended(kotlin.Array,%20android.os.UserHandle)(packageNames: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>!, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#!)` Indicates that one or more packages have been unsuspended. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onShortcutsChanged(kotlin.String,%20kotlin.collections.MutableList,%20android.os.UserHandle)(packageName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, shortcuts: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo!>, user: https://developer.android.com/reference/kotlin/android/os/UserHandle.html#)` Indicates that one or more shortcuts of any kind (dynamic, pinned, or manifest) have been added, updated or removed. |
| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onUserConfigChanged(android.content.pm.LauncherUserInfo)(launcherUserInfo: https://developer.android.com/reference/kotlin/android/content/pm/LauncherUserInfo)` Indicates `https://developer.android.com/reference/kotlin/android/content/pm/LauncherUserInfo` configs for a user have changed. |

## Public constructors

### Callback

```
Callback()
```

## Public methods

### onPackageAdded

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun onPackageAdded(
    packageName: String!, 
    user: UserHandle!
): Unit
```

Indicates that a package was added to the specified profile. If a package is added while being updated then onPackageChanged will be called instead.

| Parameters ||
|---|---|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The name of the package that was added. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#)!: The UserHandle of the profile that generated the change. |

### onPackageChanged

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun onPackageChanged(
    packageName: String!, 
    user: UserHandle!
): Unit
```

Indicates that a package was modified in the specified profile. This can happen, for example, when the package is updated or when one or more components are enabled or disabled.

This callback is also invoked when the App Lock enablement state changes for a package. See `https://developer.android.com/reference/kotlin/android/content/pm/PackageManager#getEnableAppLockIntentForPackage(kotlin.String,%20kotlin.Boolean)` for more information about App Lock.

| Parameters ||
|---|---|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The name of the package that has changed. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#)!: The UserHandle of the profile that generated the change. |

### onPackageLoadingProgressChanged

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onPackageLoadingProgressChanged(
    packageName: String, 
    user: UserHandle, 
    progress: Float
): Unit
```

Indicates that the loading progress of an installed package has changed.

| Parameters ||
|---|---|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The name of the package that has changed. This value cannot be `null`. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#): The UserHandle of the profile that generated the change. This value cannot be `null`. |
| `progress` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html): The new progress value, between \[0, 1\]. |

### onPackageRemoved

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun onPackageRemoved(
    packageName: String!, 
    user: UserHandle!
): Unit
```

Indicates that a package was removed from the specified profile. If a package is removed while being updated onPackageChanged will be called instead.

| Parameters ||
|---|---|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The name of the package that was removed. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#)!: The UserHandle of the profile that generated the change. |

### onPackagesAvailable

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun onPackagesAvailable(
    packageNames: Array<String!>!, 
    user: UserHandle!, 
    replacing: Boolean
): Unit
```

Indicates that one or more packages have become available. For example, this can happen when a removable storage card has reappeared.

| Parameters ||
|---|---|
| `packageNames` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!: The names of the packages that have become available. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#)!: The UserHandle of the profile that generated the change. |
| `replacing` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Indicates whether these packages are replacing existing ones. |

### onPackagesSuspended

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onPackagesSuspended(
    packageNames: Array<String!>!, 
    user: UserHandle!
): Unit
```

Indicates that one or more packages have been suspended. For example, this can happen when a Device Administrator suspends an applicaton.

Note: On devices running `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#P:kotlin.Int` or higher, any apps that override `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackagesSuspended(kotlin.Array,%20android.os.UserHandle,%20android.os.Bundle)` will not receive this callback.

| Parameters ||
|---|---|
| `packageNames` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!: The names of the packages that have just been suspended. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#)!: The UserHandle of the profile that generated the change. |

### onPackagesSuspended

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onPackagesSuspended(
    packageNames: Array<String!>!, 
    user: UserHandle!, 
    launcherExtras: Bundle?
): Unit
```

**Deprecated:** *`launcherExtras` should be obtained by using `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps#getSuspendedPackageLauncherExtras(kotlin.String,%20android.os.UserHandle)`. For all other cases, `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps.Callback#onPackagesSuspended(kotlin.Array,%20android.os.UserHandle)` should be used.*

Indicates that one or more packages have been suspended. A device administrator or an app with `android.permission.SUSPEND_APPS` can do this.

A suspending app with the permission `android.permission.SUSPEND_APPS` can optionally provide a `https://developer.android.com/reference/kotlin/android/os/Bundle.html#` of extra information that it deems helpful for the launcher to handle the suspended state of these packages. The contents of this `https://developer.android.com/reference/kotlin/android/os/Bundle.html#` are supposed to be a contract between the suspending app and the launcher.

| Parameters ||
|---|---|
| `packageNames` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!: The names of the packages that have just been suspended. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#)!: the user for which the given packages were suspended. |
| `launcherExtras` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?: A `https://developer.android.com/reference/kotlin/android/os/Bundle.html#` of extras for the launcher, if provided to the system, `null` otherwise. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/content/pm/PackageManager#isPackageSuspended()`
- `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps#getSuspendedPackageLauncherExtras(kotlin.String,%20android.os.UserHandle)`

### onPackagesUnavailable

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun onPackagesUnavailable(
    packageNames: Array<String!>!, 
    user: UserHandle!, 
    replacing: Boolean
): Unit
```

Indicates that one or more packages have become unavailable. For example, this can happen when a removable storage card has been removed.

| Parameters ||
|---|---|
| `packageNames` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!: The names of the packages that have become unavailable. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#)!: The UserHandle of the profile that generated the change. |
| `replacing` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Indicates whether the packages are about to be replaced with new versions. |

### onPackagesUnsuspended

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onPackagesUnsuspended(
    packageNames: Array<String!>!, 
    user: UserHandle!
): Unit
```

Indicates that one or more packages have been unsuspended. For example, this can happen when a Device Administrator unsuspends an applicaton.

| Parameters ||
|---|---|
| `packageNames` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!: The names of the packages that have just been unsuspended. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#)!: The UserHandle of the profile that generated the change. |

### onShortcutsChanged

Added in [API level 25](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onShortcutsChanged(
    packageName: String, 
    shortcuts: MutableList<ShortcutInfo!>, 
    user: UserHandle
): Unit
```

Indicates that one or more shortcuts of any kind (dynamic, pinned, or manifest) have been added, updated or removed.

Only the applications that are allowed to access the shortcut information, as defined in `https://developer.android.com/reference/kotlin/android/content/pm/LauncherApps#hasShortcutHostPermission()`, will receive it.

| Parameters ||
|---|---|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The name of the package that has the shortcuts. This value cannot be `null`. |
| `shortcuts` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[ShortcutInfo](https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo)!\>: All shortcuts from the package (dynamic, manifest and/or pinned). Only "key" information will be provided, as defined in `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutInfo#hasKeyFieldsOnly()`. This value cannot be `null`. |
| `user` | [UserHandle](https://developer.android.com/reference/kotlin/android/os/UserHandle.html#): The UserHandle of the profile that generated the change. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/content/pm/ShortcutManager`

### onUserConfigChanged

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun onUserConfigChanged(launcherUserInfo: LauncherUserInfo): Unit
```

Indicates `https://developer.android.com/reference/kotlin/android/content/pm/LauncherUserInfo` configs for a user have changed. The new `https://developer.android.com/reference/kotlin/android/content/pm/LauncherUserInfo` is given as a parameter. `https://developer.android.com/reference/kotlin/android/content/pm/LauncherUserInfo#getUserConfig()` to get the updated user configs.

| Parameters ||
|---|---|
| `launcherUserInfo` | [LauncherUserInfo](https://developer.android.com/reference/kotlin/android/content/pm/LauncherUserInfo): The LauncherUserInfo of the user/profile whose configs have changed. This value cannot be `null`. |