How to increase ringer volume and notifications programmatically in Android
I am trying to turn on the normal ringer mode and increase the volume programmatically.
AudioManager mobilemode = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
// int streamMaxVolume = mobilemode.getStreamMaxVolume(AudioManager.STREAM_RING);
switch (mobilemode.getRingerMode()) {
case AudioManager.RINGER_MODE_SILENT:
Log.i("MyApp","Silent mode");
mobilemode.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
mobilemode.setStreamVolume (AudioManager.STREAM_MUSIC,mobilemode.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0);
break;
case AudioManager.RINGER_MODE_VIBRATE:
Log.i("MyApp","Vibrate mode");
mobilemode.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
mobilemode.setStreamVolume (AudioManager.STREAM_MUSIC,mobilemode.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0);
break;
case AudioManager.RINGER_MODE_NORMAL:
Log.i("MyApp","Normal mode");
break;
}
But this allows the normal mode. But I can't turn up the volume.
Please allow me to increase the volume programmatically in any way.
+3
source to share