set Ring Volume - Android android.provider

Android examples for android.provider:Settings

Description

set Ring Volume

Demo Code

import android.content.Context;
import android.provider.Settings;

public class Main {

  public static boolean setRingVolume(Context context, int ringVloume) {
    if (ringVloume < 0) {
      ringVloume = 0;//  ww  w. j  av a  2s .  c  om
    } else if (ringVloume > 7) {
      ringVloume = ringVloume % 7;
      if (ringVloume == 0) {
        ringVloume = 7;
      }
    }
    return Settings.System.putInt(context.getContentResolver(), Settings.System.VOLUME_MUSIC, ringVloume);
  }

}

Related Tutorials