如何增加铃声在Android中以编程方式通知音量 [英] How to increase the ringer & notification volume programmatically in android

查看:206
本文介绍了如何增加铃声在Android中以编程方式通知音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试启用振铃器正常模式并以编程方式增加音量.

I am trying to enable the ringer normal 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 It enable the normal mode. But I can not increase the volume.

请让我以任何方式以编程方式增加音量.

Please let me any way to increase the volume programmatically..

推荐答案

替换行

mobilemode.setStreamVolume (AudioManager.STREAM_MUSIC,mobilemode.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0);

在下面一行

mobilemode.setStreamVolume(AudioManager.STREAM_RING,audioManager.getStreamMaxVolume(AudioManager.STREAM_RING),0);

这篇关于如何增加铃声在Android中以编程方式通知音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆