Android应用中怎么设置系统铃声与音量的大小?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。通过程序获取android系统手机的铃声和音量。同样,设置铃声和音
Android应用中怎么设置系统铃声与音量的大小?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
通过程序获取android系统手机的铃声和音量。同样,设置铃声和音量的方法也很简单!
设置音量的方法也很简单,AudioManager提供了方法:
public voidsetStreamVolume(intstreamType,intindex,intflags)
其中streamType有内置的常量,去文档里面就可以看到。
JAVA代码:
AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);//通话音量int max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_VOICE_CALL );int current = mAudioManager.getStreamVolume( AudioManager.STREAM_VOICE_CALL );Log.d("ViocE_CALL", "max : " + max + " current : " + current);//系统音量max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_SYSTEM );current = mAudioManager.getStreamVolume( AudioManager.STREAM_SYSTEM );Log.d("SYSTEM", "max : " + max + " current : " + current);//铃声音量max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_RING );current = mAudioManager.getStreamVolume( AudioManager.STREAM_RING );Log.d("RING", "max : " + max + " current : " + current);//音乐音量max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_MUSIC );current = mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC );Log.d("MUSIC", "max : " + max + " current : " + current);//提示声音音量max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_ALARM );current = mAudioManager.getStreamVolume( AudioManager.STREAM_ALARM );Log.d("ALARM", "max : " + max + " current : " + current);
--结束END--
本文标题: android应用中怎么设置系统铃声与音量的大小
本文链接: https://www.lsjlt.com/news/222824.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0