Example usage for android.media AudioManager STREAM_RING

List of usage examples for android.media AudioManager STREAM_RING

Introduction

In this page you can find the example usage for android.media AudioManager STREAM_RING.

Prototype

int STREAM_RING

To view the source code for android.media AudioManager STREAM_RING.

Click Source Link

Document

Used to identify the volume of audio streams for the phone ring

Usage

From source file:net.hyx.app.volumenotification.NotificationFactory.java

void setVolume(int position) {
    int selection = settings.getButtonSelection(position);
    int direction = AudioManager.ADJUST_SAME;
    int type = STREAM_TYPES[selection];

    if (type == AudioManager.STREAM_MUSIC && settings.getToggleMute()) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            direction = AudioManager.ADJUST_TOGGLE_MUTE;
        } else {/*from   w  w  w. j  a va2  s.  c o  m*/
            _mute = !_mute;
            audio.setStreamMute(type, _mute);
        }
    } else if (type == AudioManager.STREAM_RING && settings.getToggleSilent()) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            direction = AudioManager.ADJUST_TOGGLE_MUTE;
        } else {
            _silent = !_silent;
            audio.setStreamMute(type, _silent);
        }
    }
    audio.adjustStreamVolume(type, direction, AudioManager.FLAG_SHOW_UI);
}

From source file:com.bytestemplar.tonedef.touchpad.TouchPadActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.touchpad_container);
    setVolumeControlStream(AudioManager.STREAM_RING);
    _preferences = PreferenceManager.getDefaultSharedPreferences(this);

    _et_dialing_string = (EditText) findViewById(R.id.etDialingString);
    _buttons = new ToneButtonList(this);
}

From source file:com.metinkale.prayerapp.vakit.AlarmReceiver.java

public static int getStreamType(Context c) {
    String ezanvolume = PreferenceManager.getDefaultSharedPreferences(c).getString("ezanvolume", "noti");
    switch (ezanvolume) {
    case "alarm":
        return AudioManager.STREAM_ALARM;
    case "media":
        return AudioManager.STREAM_MUSIC;
    default:/*from  w ww . j  a v  a2 s  . c o m*/
        return AudioManager.STREAM_RING;

    }
}

From source file:gstb.fd.eofficial.oa.im.widget.chatrow.EaseChatRowVoicePlayClickListener.java

public void playVoice(String filePath) {
    Log.e("sssssss", "sssssssssssssss");
    if (!(new File(filePath).exists())) {
        return;/*from ww  w .  j av a  2  s .co m*/
    }
    //      playMsgId = message.getMsgId();
    AudioManager audioManager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);

    mediaPlayer = new MediaPlayer();
    //      if (EaseUI.getInstance().getSettingsProvider().isSpeakerOpened()) {
    audioManager.setMode(AudioManager.MODE_NORMAL);
    audioManager.setSpeakerphoneOn(true);
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_RING);
    //      } else {
    //         audioManager.setSpeakerphoneOn(false);// 
    // ?Earpiece???
    //         audioManager.setMode(AudioManager.MODE_IN_CALL);
    //         mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
    //      }
    try {
        mediaPlayer.setDataSource(filePath);
        mediaPlayer.prepare();
        mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

            @Override
            public void onCompletion(MediaPlayer mp) {
                // TODO Auto-generated method stub
                mediaPlayer.release();
                mediaPlayer = null;
                stopPlayVoice(); // stop animation
            }

        });
        isPlaying = true;
        currentPlayListener = this;
        mediaPlayer.start();
        showAnimation();

        // ?
        if (message.direct() == EMMessage.Direct.RECEIVE) {

            //             if (!message.isAcked() && chatType == EMMessage.ChatType.Chat) {
            //                       // ??
            ////                     EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
            //             }
            if (!message.isListened() && iv_read_status != null
                    && iv_read_status.getVisibility() == View.VISIBLE) {
                // ????
                iv_read_status.setVisibility(View.INVISIBLE);
                message.setListened(true);
                MessageDao.instance(activity).updateListen(message.getMsgId());
                //               EMClient.getInstance().chatManager().setMessageListened(message);
            }

        }

    } catch (Exception e) {
        System.out.println();
    }
}

From source file:com.google.android.car.kitchensink.volume.VolumeTestFragment.java

private static String streamToName(int stream) {
    switch (stream) {
    case AudioManager.STREAM_ALARM:
        return "Alarm";
    case AudioManager.STREAM_MUSIC:
        return "Music";
    case AudioManager.STREAM_NOTIFICATION:
        return "Notification";
    case AudioManager.STREAM_RING:
        return "Ring";
    case AudioManager.STREAM_VOICE_CALL:
        return "Call";
    case AudioManager.STREAM_SYSTEM:
        return "System";
    default://from   ww w .  ja v a 2 s.  c  o m
        return "Unknown";
    }
}

From source file:com.sublimis.urgentcallfilter.Magic.java

private void setRingerVolume() {
    if (MyPreference.isRingVolumeOverriden() || mRingerModeOriginal == AudioManager.RINGER_MODE_NORMAL) {
        if (mAudioManager != null) {
            int volumeToSet = (int) Math.round((double) MyPreference.getRingVolume() * mVolumeMax / 10.);

            if (mRingerModeOriginal == AudioManager.RINGER_MODE_NORMAL)
                volumeToSet = mVolumeMax;

            MyPreference.setOriginalRingVolume(mVolumeOriginal);

            mAudioManager.setStreamVolume(AudioManager.STREAM_RING, volumeToSet, 0);
        }//from   w  w  w.j a v a 2s .  com
    } else {
        MyPreference.setOriginalRingVolume(-1);
    }
}

From source file:com.sublimis.urgentcallfilter.Magic.java

private void restoreRingerVolume() {
    int originalVolume = MyPreference.getOriginalRingVolume();

    if (originalVolume >= 0) {
        if (mAudioManager != null) {
            mAudioManager.setStreamVolume(AudioManager.STREAM_RING, originalVolume, 0);
        }/*from  www . ja  v a2 s  .co m*/

        MyPreference.setOriginalRingVolume(-1);
    }
}

From source file:net.hyx.app.volumenotification.factory.NotificationFactory.java

private int getStreamFlag(int type) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if ((type == AudioManager.STREAM_MUSIC && settings.getToggleMute())
                || (type == AudioManager.STREAM_RING && settings.getToggleSilent())) {
            return AudioManager.ADJUST_TOGGLE_MUTE;
        }//from w  w w  .  java  2  s . c o  m
    }
    return AudioManager.ADJUST_SAME;
}

From source file:org.wso2.iot.agent.AlertActivity.java

/**
 * This method stops the device ring.//from  w  w  w  .ja v  a2  s . c  o  m
 */
private void stopRing() {
    if (defaultRingtone != null && defaultRingtone.isPlaying()) {
        defaultRingtone.stop();
    }
    audio.setStreamVolume(AudioManager.STREAM_RING, ringerVolume, DEFAULT_FLAG);
    audio.setRingerMode(ringerMode);
}

From source file:org.wso2.emm.agent.AlertActivity.java

/**
 * This method stops the device ring./*from  w w  w  .ja v a2s  .  c o  m*/
 */
private void stopRing() {
    if (defaultRingtone != null && defaultRingtone.isPlaying()) {
        defaultRingtone.stop();
    }
    audio.setStreamVolume(AudioManager.STREAM_RING, DEFAULT_VOLUME, DEFAULT_FLAG);
    audio.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}