Added in API level 30

StorageVolumeCallback


open class StorageVolumeCallback
kotlin.Any
   ↳ android.os.storage.StorageManager.StorageVolumeCallback

Callback that delivers StorageVolume related events.

For example, this can be used to detect when a volume changes to the Environment.MEDIA_MOUNTED or Environment.MEDIA_UNMOUNTED states.

Summary

Public constructors

Public methods
open Unit

Called when StorageVolume.getState() changes, such as changing to the Environment.MEDIA_MOUNTED or Environment.MEDIA_UNMOUNTED states.

Public constructors

StorageVolumeCallback

StorageVolumeCallback()

Public methods

onStateChanged

Added in API level 30
open fun onStateChanged(volume: StorageVolume): Unit

Called when StorageVolume.getState() changes, such as changing to the Environment.MEDIA_MOUNTED or Environment.MEDIA_UNMOUNTED states.

The given argument is a snapshot in time and can be used to process events in the order they occurred, or you can call StorageManager.getStorageVolumes() to observe the latest value.

Parameters
volume StorageVolume: This value cannot be null.