Android APIs
public class

Ringtone

extends Object
java.lang.Object
   ↳ android.media.Ringtone

Class Overview

Ringtone provides a quick method for playing a ringtone, notification, or other similar types of sounds.

For ways of retrieving Ringtone objects or to show a ringtone picker, see RingtoneManager.

See Also

Summary

Public Methods
AudioAttributes getAudioAttributes()
Returns the AudioAttributes used by this object.
int getStreamType()
This method was deprecated in API level 21. use of stream types is deprecated, see setAudioAttributes(AudioAttributes)
String getTitle(Context context)
Returns a human-presentable title for ringtone.
boolean isPlaying()
Whether this ringtone is currently playing.
void play()
Plays the ringtone.
void setAudioAttributes(AudioAttributes attributes)
Sets the AudioAttributes for this ringtone.
void setStreamType(int streamType)
This method was deprecated in API level 21. use setAudioAttributes(AudioAttributes)
void stop()
Stops a playing ringtone.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public AudioAttributes getAudioAttributes ()

Added in API level 21

Returns the AudioAttributes used by this object.

Returns

public int getStreamType ()

Added in API level 1

This method was deprecated in API level 21.
use of stream types is deprecated, see setAudioAttributes(AudioAttributes)

Gets the stream type where this ringtone will be played.

Returns

public String getTitle (Context context)

Added in API level 1

Returns a human-presentable title for ringtone. Looks in media content provider. If not in either, uses the filename

Parameters
context A context used for querying.

public boolean isPlaying ()

Added in API level 1

Whether this ringtone is currently playing.

Returns
  • True if playing, false otherwise.

public void play ()

Added in API level 1

Plays the ringtone.

public void setAudioAttributes (AudioAttributes attributes)

Added in API level 21

Sets the AudioAttributes for this ringtone.

Parameters
attributes the non-null attributes characterizing this ringtone.

public void setStreamType (int streamType)

Added in API level 1

This method was deprecated in API level 21.
use setAudioAttributes(AudioAttributes)

Sets the stream type where this ringtone will be played.

Parameters
streamType The stream, see AudioManager.

public void stop ()

Added in API level 1

Stops a playing ringtone.