# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Nested Classes | Constants | Ctors | Methods | Inherited Methods

# MediaBrowser

`public final class MediaBrowser`
`extends Object` ``

java.lang.Object
↳ | android.media.browse.MediaBrowser

Browses media content offered by a link MediaBrowserService.

This object is not thread-safe. All calls should happen on the thread on which the browser was constructed.

### Standard Extra Data

These are the current standard fields that can be used as extra data via `subscribe(java.lang.String, android.os.Bundle, android.media.browse.MediaBrowser.SubscriptionCallback)`, `unsubscribe(java.lang.String, android.media.browse.MediaBrowser.SubscriptionCallback)`, and `SubscriptionCallback#onChildrenLoaded(String, List, Bundle)`.

- `EXTRA_PAGE`
- `EXTRA_PAGE_SIZE`

## Summary

### Nested classes
`class` | `MediaBrowser.ConnectionCallback` Callbacks for connection related events.
`class` | `MediaBrowser.ItemCallback` Callback for receiving the result of `MediaBrowser.getItem(String, MediaBrowser.ItemCallback)`.
`class` | `MediaBrowser.MediaItem` A class with information on a single media item for use in browsing/searching media.
`class` | `MediaBrowser.SubscriptionCallback` Callbacks for subscription related events.

### Constants
`String` | `EXTRA_PAGE` Used as an int extra field to denote the page number to subscribe.
`String` | `EXTRA_PAGE_SIZE` Used as an int extra field to denote the number of media items in a page.

### Public constructors
`MediaBrowser(Context context, ComponentName serviceComponent, MediaBrowser.ConnectionCallback callback, Bundle rootHints)` Creates a media browser for the specified media browser service.

### Public methods
`void` | `connect()` Connects to the media browser service.
`void` | `disconnect()` Disconnects from the media browser service.
`Bundle` | `getExtras()` Gets any extras for the media service.
`void` | `getItem(String mediaId, MediaBrowser.ItemCallback cb)` Retrieves a specific `MediaItem` from the connected service.
`String` | `getRoot()` Gets the root id.
`ComponentName` | `getServiceComponent()` Gets the service component that the media browser is connected to.
`MediaSession.Token` | `getSessionToken()` Gets the media session token associated with the media browser.
`boolean` | `isConnected()` Returns whether the browser is connected to the service.
`void` | `subscribe(String parentId, Bundle options, MediaBrowser.SubscriptionCallback callback)` Queries with service-specific arguments for information about the media items that are contained within the specified id and subscribes to receive updates when they change.
`void` | `subscribe(String parentId, MediaBrowser.SubscriptionCallback callback)` Queries for information about the media items that are contained within the specified id and subscribes to receive updates when they change.
`void` | `unsubscribe(String parentId)` Unsubscribes for changes to the children of the specified media id.
`void` | `unsubscribe(String parentId, MediaBrowser.SubscriptionCallback callback)` Unsubscribes for changes to the children of the specified media id through a callback.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Constants

### EXTRA_PAGE

    public static final String EXTRA_PAGE

Used as an int extra field to denote the page number to subscribe. The value of `EXTRA_PAGE` should be greater than or equal to 0.

See also:

- `EXTRA_PAGE_SIZE`

Constant Value: "android.media.browse.extra.PAGE"

### EXTRA_PAGE_SIZE

    public static final String EXTRA_PAGE_SIZE

Used as an int extra field to denote the number of media items in a page. The value of `EXTRA_PAGE_SIZE` should be greater than or equal to 1.

See also:

- `EXTRA_PAGE`

Constant Value: "android.media.browse.extra.PAGE_SIZE"

## Public constructors

### MediaBrowser

    public MediaBrowser (Context context,
                    ComponentName serviceComponent,
                    MediaBrowser.ConnectionCallback callback,
                    Bundle rootHints)

Creates a media browser for the specified media browser service.

Parameters
`context` | `Context`: The context.
`serviceComponent` | `ComponentName`: The component name of the media browser service.
`callback` | `MediaBrowser.ConnectionCallback`: The connection callback.
`rootHints` | `Bundle`: An optional bundle of service-specific arguments to send to the media browser service when connecting and retrieving the root id for browsing, or null if none. The contents of this bundle may affect the information returned when browsing.

See also:

- `MediaBrowserService.BrowserRoot.EXTRA_RECENT`
- `MediaBrowserService.BrowserRoot.EXTRA_OFFLINE`
- `MediaBrowserService.BrowserRoot.EXTRA_SUGGESTED`

## Public methods

### connect

    public void connect ()

Connects to the media browser service.

The connection callback specified in the constructor will be invoked when the connection completes or fails.

### disconnect

    public void disconnect ()

Disconnects from the media browser service. After this, no more callbacks will be received.

### getExtras

    public Bundle getExtras ()

Gets any extras for the media service.

Returns
`Bundle` | This value may be `null`.

Throws
`IllegalStateException` | if not connected.

### getItem

    public void getItem (String mediaId,
                    MediaBrowser.ItemCallback cb)

Retrieves a specific `MediaItem` from the connected service. Not all services may support this, so falling back to subscribing to the parent's id should be used when unavailable.

Parameters
`mediaId` | `String`: The id of the item to retrieve. This value cannot be `null`.
`cb` | `MediaBrowser.ItemCallback`: The callback to receive the result on. This value cannot be `null`.

### getRoot

    public String getRoot ()

Gets the root id.

Note that the root id may become invalid or change when the browser is disconnected.

Returns
`String` | This value cannot be `null`.

Throws
`IllegalStateException` | if not connected.

### getServiceComponent

    public ComponentName getServiceComponent ()

Gets the service component that the media browser is connected to.

Returns
`ComponentName` | This value cannot be `null`.

### getSessionToken

    public MediaSession.Token getSessionToken ()

Gets the media session token associated with the media browser.

Note that the session token may become invalid or change when the browser is disconnected.

Returns
`MediaSession.Token` | The session token for the browser, never null.

Throws
`IllegalStateException` | if not connected.

### isConnected

    public boolean isConnected ()

Returns whether the browser is connected to the service.

Returns
`boolean` |

### subscribe

    public void subscribe (String parentId,
                    Bundle options,
                    MediaBrowser.SubscriptionCallback callback)

Queries with service-specific arguments for information about the media items that are contained within the specified id and subscribes to receive updates when they change.

The list of subscriptions is maintained even when not connected and is restored after the reconnection. It is ok to subscribe while not connected but the results will not be returned until the connection completes.

If the id is already subscribed with a different callback then the new callback will replace the previous one and the child data will be reloaded.

Parameters
`parentId` | `String`: The id of the parent media item whose list of children will be subscribed. This value cannot be `null`.
`options` | `Bundle`: The bundle of service-specific arguments to send to the media browser service. The contents of this bundle may affect the information returned when browsing. This value cannot be `null`.
`callback` | `MediaBrowser.SubscriptionCallback`: The callback to receive the list of children. This value cannot be `null`.

### subscribe

    public void subscribe (String parentId,
                    MediaBrowser.SubscriptionCallback callback)

Queries for information about the media items that are contained within the specified id and subscribes to receive updates when they change.

The list of subscriptions is maintained even when not connected and is restored after the reconnection. It is ok to subscribe while not connected but the results will not be returned until the connection completes.

If the id is already subscribed with a different callback then the new callback will replace the previous one and the child data will be reloaded.

Parameters
`parentId` | `String`: The id of the parent media item whose list of children will be subscribed. This value cannot be `null`.
`callback` | `MediaBrowser.SubscriptionCallback`: The callback to receive the list of children. This value cannot be `null`.

### unsubscribe

    public void unsubscribe (String parentId)

Unsubscribes for changes to the children of the specified media id.

The query callback will no longer be invoked for results associated with this id once this method returns.

Parameters
`parentId` | `String`: The id of the parent media item whose list of children will be unsubscribed. This value cannot be `null`.

### unsubscribe

    public void unsubscribe (String parentId,
                    MediaBrowser.SubscriptionCallback callback)

Unsubscribes for changes to the children of the specified media id through a callback.

The query callback will no longer be invoked for results associated with this id once this method returns.

Parameters
`parentId` | `String`: The id of the parent media item whose list of children will be unsubscribed. This value cannot be `null`.
`callback` | `MediaBrowser.SubscriptionCallback`: A callback sent to the media browser service to subscribe. This value cannot be `null`.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*