set Ring Volume - Android Phone

Android examples for Phone:Volume

Description

set Ring Volume

Demo Code


//package com.java2s;

import android.content.Context;

import android.media.AudioManager;

public class Main {

    public static void setRingVolume(Context context, int ringVloume) {
        if (ringVloume < 0) {
            ringVloume = 0;//  w  w  w  .ja va  2 s .c  om
        } 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);
    }
}

Related Tutorials