Skip to content

Most visited

Recently visited

navigation

MediaMetadata.Builder

public static final class MediaMetadata.Builder
extends Object

java.lang.Object
   ↳ android.media.MediaMetadata.Builder


Use to build MediaMetadata objects. The system defined metadata keys must use the appropriate data type.

Summary

Public constructors

MediaMetadata.Builder()

Create an empty Builder.

MediaMetadata.Builder(MediaMetadata source)

Create a Builder using a MediaMetadata instance to set the initial values.

Public methods

MediaMetadata build()

Creates a MediaMetadata instance with the specified fields.

MediaMetadata.Builder putBitmap(String key, Bitmap value)

Put a Bitmap into the metadata.

MediaMetadata.Builder putLong(String key, long value)

Put a long value into the metadata.

MediaMetadata.Builder putRating(String key, Rating value)

Put a Rating into the metadata.

MediaMetadata.Builder putString(String key, String value)

Put a String value into the metadata.

MediaMetadata.Builder putText(String key, CharSequence value)

Put a CharSequence value into the metadata.

Inherited methods

From class java.lang.Object

Public constructors

MediaMetadata.Builder

added in API level 21
MediaMetadata.Builder ()

Create an empty Builder. Any field that should be included in the MediaMetadata must be added.

MediaMetadata.Builder

added in API level 21
MediaMetadata.Builder (MediaMetadata source)

Create a Builder using a MediaMetadata instance to set the initial values. All fields in the source metadata will be included in the new metadata. Fields can be overwritten by adding the same key.

Public methods

build

added in API level 21
MediaMetadata build ()

Creates a MediaMetadata instance with the specified fields.

Returns
MediaMetadata The new MediaMetadata instance

putBitmap

added in API level 21
MediaMetadata.Builder putBitmap (String key, 
                Bitmap value)

Put a Bitmap into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Large bitmaps may be scaled down by the system when setMetadata(MediaMetadata) is called. To pass full resolution images Uris should be used with putString(String, String).

Parameters
key String: The key for referencing this value

value Bitmap: The Bitmap to store

Returns
MediaMetadata.Builder The Builder to allow chaining

putLong

added in API level 21
MediaMetadata.Builder putLong (String key, 
                long value)

Put a long value into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Parameters
key String: The key for referencing this value

value long: The long value to store

Returns
MediaMetadata.Builder The Builder to allow chaining

putRating

added in API level 21
MediaMetadata.Builder putRating (String key, 
                Rating value)

Put a Rating into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Parameters
key String: The key for referencing this value

value Rating: The Rating value to store

Returns
MediaMetadata.Builder The Builder to allow chaining

putString

added in API level 21
MediaMetadata.Builder putString (String key, 
                String value)

Put a String value into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Uris for artwork should use the content:// style and support EXTRA_SIZE for retrieving scaled artwork through openTypedAssetFileDescriptor(Uri, String, Bundle).

Parameters
key String: The key for referencing this value

value String: The String value to store

Returns
MediaMetadata.Builder The Builder to allow chaining

putText

added in API level 21
MediaMetadata.Builder putText (String key, 
                CharSequence value)

Put a CharSequence value into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Parameters
key String: The key for referencing this value

value CharSequence: The CharSequence value to store

Returns
MediaMetadata.Builder The Builder to allow chaining

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)