Android examples for Media:Audio
Gets current ring volume from phone
import android.content.Context; import android.media.AudioManager; public class Main { /**//from w ww .j a v a 2s . c om * Gets current ring volume from phone * * @param context * - context under which the AlarmHelper operates * @return - volumeId for the current ring volume */ private static int getVolumeIdForCurrentRingVolume(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); int currentMode = audioManager.getRingerMode(); switch (currentMode) { case AudioManager.RINGER_MODE_NORMAL: return 1; case AudioManager.RINGER_MODE_VIBRATE: return 2; case AudioManager.RINGER_MODE_SILENT: return 3; default: return -1; } } }