belongs to Maven artifact com.android.support:support-media-compat:28.0.0-alpha1
VolumeProviderCompat
  public
  abstract
  class
  VolumeProviderCompat
    extends Object
| java.lang.Object | |
| ↳ | android.support.v4.media.VolumeProviderCompat | 
Handles requests to adjust or set the volume on a session. This is also used
 to push volume updates back to the session after a request has been handled.
 You can set a volume provider on a session by calling
 setPlaybackToRemote(VolumeProviderCompat).
Summary
| Nested classes | |
|---|---|
| 
        class | VolumeProviderCompat.CallbackListens for changes to the volume. | 
| Constants | |
|---|---|
| int | VOLUME_CONTROL_ABSOLUTEThe volume control uses an absolute value. | 
| int | VOLUME_CONTROL_FIXEDThe volume is fixed and can not be modified. | 
| int | VOLUME_CONTROL_RELATIVEThe volume control uses relative adjustment via
  | 
| Public constructors | |
|---|---|
| 
      VolumeProviderCompat(int volumeControl, int maxVolume, int currentVolume)
      Create a new volume provider for handling volume events. | |
| Public methods | |
|---|---|
| 
        final
        int | 
      getCurrentVolume()
      Get the current volume of the provider. | 
| 
        final
        int | 
      getMaxVolume()
      Get the maximum volume this provider allows. | 
| 
        final
        int | 
      getVolumeControl()
      Get the volume control type that this volume provider uses. | 
| 
        Object | 
      getVolumeProvider()
      Gets the underlying framework  | 
| 
        void | 
      onAdjustVolume(int direction)
      Override to handle requests to adjust the volume of the current output. | 
| 
        void | 
      onSetVolumeTo(int volume)
      Override to handle requests to set the volume of the current output. | 
| 
        void | 
      setCallback(VolumeProviderCompat.Callback callback)
      Sets a callback to receive volume changes. | 
| 
        final
        void | 
      setCurrentVolume(int currentVolume)
      Set the current volume and notify the system that the volume has been changed. | 
| Inherited methods | |
|---|---|
|  From
class 
    java.lang.Object
 | |
Constants
VOLUME_CONTROL_ABSOLUTE
int VOLUME_CONTROL_ABSOLUTE
The volume control uses an absolute value. It may be adjusted using
 onAdjustVolume(int) or set directly using
 onSetVolumeTo(int).
Constant Value: 2 (0x00000002)
VOLUME_CONTROL_FIXED
int VOLUME_CONTROL_FIXED
The volume is fixed and can not be modified. Requests to change volume should be ignored.
Constant Value: 0 (0x00000000)
VOLUME_CONTROL_RELATIVE
int VOLUME_CONTROL_RELATIVE
The volume control uses relative adjustment via
 onAdjustVolume(int). Attempts to set the volume to a specific
 value should be ignored.
Constant Value: 1 (0x00000001)
Public constructors
VolumeProviderCompat
VolumeProviderCompat (int volumeControl,
                int maxVolume,
                int currentVolume)Create a new volume provider for handling volume events. You must specify the type of volume control and the maximum volume that can be used.
| Parameters | |
|---|---|
| volumeControl | int: The method for controlling volume that is used by
            this provider. | 
| maxVolume | int: The maximum allowed volume. | 
| currentVolume | int: The current volume. | 
Public methods
getCurrentVolume
int getCurrentVolume ()
Get the current volume of the provider.
| Returns | |
|---|---|
| int | The current volume. | 
getMaxVolume
int getMaxVolume ()
Get the maximum volume this provider allows.
| Returns | |
|---|---|
| int | The max allowed volume. | 
getVolumeControl
int getVolumeControl ()
Get the volume control type that this volume provider uses.
| Returns | |
|---|---|
| int | The volume control type for this volume provider | 
getVolumeProvider
Object getVolumeProvider ()
Gets the underlying framework VolumeProvider object.
 
This method is only supported on API 21+.
| Returns | |
|---|---|
| Object | An equivalent VolumeProviderobject, or null if none. | 
onAdjustVolume
void onAdjustVolume (int direction)
Override to handle requests to adjust the volume of the current output.
| Parameters | |
|---|---|
| direction | int: The direction to adjust the volume in. | 
onSetVolumeTo
void onSetVolumeTo (int volume)
Override to handle requests to set the volume of the current output.
| Parameters | |
|---|---|
| volume | int: The volume to set the output to. | 
setCallback
void setCallback (VolumeProviderCompat.Callback callback)
Sets a callback to receive volume changes.
Used internally by the support library.
| Parameters | |
|---|---|
| callback | VolumeProviderCompat.Callback | 
setCurrentVolume
void setCurrentVolume (int currentVolume)
Set the current volume and notify the system that the volume has been changed.
| Parameters | |
|---|---|
| currentVolume | int: The current volume of the output. | 
- Classes- AudioAttributesCompat
- AudioAttributesCompat.Builder
- MediaBrowserCompat
- MediaBrowserCompat.ConnectionCallback
- MediaBrowserCompat.CustomActionCallback
- MediaBrowserCompat.ItemCallback
- MediaBrowserCompat.MediaItem
- MediaBrowserCompat.SearchCallback
- MediaBrowserCompat.SubscriptionCallback
- MediaBrowserServiceCompat
- MediaBrowserServiceCompat.BrowserRoot
- MediaBrowserServiceCompat.Result
- MediaDescriptionCompat
- MediaDescriptionCompat.Builder
- MediaMetadataCompat
- MediaMetadataCompat.Builder
- RatingCompat
- VolumeProviderCompat
- VolumeProviderCompat.Callback
 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
