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:Main.java

public static int getRingVolume(Context context) {
    return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
            .getStreamVolume(AudioManager.STREAM_RING);
}

From source file:Main.java

public static final int audioVolume(Context ctx) {
    AudioManager audio = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
    return audio.getStreamVolume(AudioManager.STREAM_RING);
}

From source file:Main.java

/** Returns the volume for the ringer. */
public static int getRingerVolume(Context context) {
    AudioManager am = getAudioManager(context);
    return am.getStreamVolume(AudioManager.STREAM_RING);
}

From source file:Main.java

public static void setRingVolume(Context context, int ringVloume) {
    if (ringVloume < 0) {
        ringVloume = 0;/*  w  ww. j  ava  2 s  .  com*/
    } else if (ringVloume > 7) {
        ringVloume = ringVloume % 7;
        if (ringVloume == 0) {
            ringVloume = 7;
        }
    }

    ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_RING,
            ringVloume, AudioManager.FLAG_PLAY_SOUND);
}

From source file:Main.java

public static void setCurrentRingerMode(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) {
        currentMode = AudioManager.RINGER_MODE_NORMAL;
        currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
        Log.i("Current Mode Normal", currentVolume + "");
        Log.i("Vlaue of", currentMode + "");
    } else if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
        currentMode = AudioManager.RINGER_MODE_VIBRATE;
        Log.i("Current Mode Vibrate", currentVolume + "");
        Log.i("Vlaue of", currentMode + "");
    } else if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
        currentMode = AudioManager.RINGER_MODE_SILENT;
        Log.i("Current Mode Silent", currentVolume + "");
        Log.i("Vlaue of", currentMode + "");
    } else {/*from   w ww .ja v  a 2 s  .c o m*/
        Log.i("Nothing ", "Matched above");
    }

}

From source file:Main.java

public static void setAudioManage(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
    audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
    audioManager.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0);
    audioManager.setStreamVolume(AudioManager.STREAM_DTMF, 0, 0);
    audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, 0, 0);
    audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, 0);
}

From source file:Main.java

public static void playRingtone(Context context, int type) {
    //        mediaPlayer = MediaPlayer.create(context, getDefaultRingtoneUri(context, type));
    //        mediaPlayer.setLooping(true);
    //        mediaPlayer.setVolume(100, 100);
    //        mediaPlayer.setAudioStreamType(AudioManager.STREAM_RING);
    ///*from w  w  w.j a va2  s  .co  m*/
    //        mediaPlayer.start();

    ringtone = getDefaultRingtone(context, type);
    ringtone.setStreamType(AudioManager.STREAM_RING);
    ringtone.play();

}

From source file:Main.java

public static void setRinger2Normal(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
    //setting the volume
    audioManager.setStreamVolume(AudioManager.STREAM_RING, currentVolume, 0);
    Log.i("HelperFunctions ", "Normal method called");
}

From source file:com.pixate.freestyle.fragment.ButtonsFragment.java

/** Set the volumn controling to seek bar */
private void setSeekBar(SeekBar seek) {
    AudioManager audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
    seek.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_RING));
    seek.setProgress(m_nAlarmVolum);//from w  ww . j  av  a 2  s  . c om
    seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar arg0) {

        }

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean arg2) {
            m_nAlarmVolum = progress;

            AudioManager audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
            audioManager.setStreamVolume(AudioManager.STREAM_RING, m_nAlarmVolum,
                    AudioManager.FLAG_ALLOW_RINGER_MODES | AudioManager.FLAG_PLAY_SOUND);
        }
    });
}

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

public Magic(Context context, String number, boolean isRingStart) {
    if (context != null) {
        mContext = context;//ww  w  .  jav a  2 s .co  m
        mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        mIsRinging = isRingStart;
        mNumber = number;

        if (mAudioManager != null) {
            mRingerModeOriginal = mAudioManager.getRingerMode();
            mVolumeOriginal = mAudioManager.getStreamVolume(AudioManager.STREAM_RING);
            mVolumeMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
        }

        MyPreference.setContext(context);
    }
}