Example usage for android.media Ringtone setStreamType

List of usage examples for android.media Ringtone setStreamType

Introduction

In this page you can find the example usage for android.media Ringtone setStreamType.

Prototype

@Deprecated
public void setStreamType(int streamType) 

Source Link

Document

Sets the stream type where this ringtone will be played.

Usage

From source file:Main.java

public static void playNotificationSound(Context context) {
    Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    if (uri != null) {
        Ringtone rt = RingtoneManager.getRingtone(context, uri);
        if (rt != null) {
            rt.setStreamType(AudioManager.STREAM_NOTIFICATION);
            rt.play();//w  ww . ja v  a  2s.c  om
        }
    }
}

From source file:de.j4velin.chess.Main.java

@Override
public void onTurnBasedMatchReceived(final TurnBasedMatch match) {
    if (BuildConfig.DEBUG)
        Logger.log("Main onTurnBasedMatchReceived: " + match.getMatchId());
    if (match.getTurnStatus() == TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN
            && match.getStatus() == TurnBasedMatch.MATCH_STATUS_ACTIVE) {
        final Ringtone tone = RingtoneManager.getRingtone(this,
                RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION));
        tone.setStreamType(AudioManager.STREAM_NOTIFICATION);
        tone.play();//from   w  ww  .j a  va  2 s  .  c  o  m
    }
    if (startFragment != null && startFragment.isVisible()) {
        startFragment.loadMatches();
    }
    if (gameFragment != null && gameFragment.isVisible()
            && match.getMatchId().equals(gameFragment.currentMatch)) {
        if (Game.load(match.getData(), match, mGoogleApiClient)) {
            gameFragment.update(match.getStatus() != TurnBasedMatch.MATCH_STATUS_ACTIVE
                    && match.getStatus() != TurnBasedMatch.MATCH_STATUS_AUTO_MATCHING);
        } else {
            updateApp();
        }
    }
}