zoukankan      html  css  js  c++  java
  • (转)Android 程序获取、设置铃声、音量、静音、扬声器

    Android 程序获取、设置铃声和音量 
    通过程序获取android系统手机的铃声和音量。同样,设置铃声和音量的方法也很简单! 

    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); 

     

    设置音量的方法也很简单,AudioManager提供了方法: 
    public void setStreamVolume(int streamType, int index, int flags) 
    streamType为铃声类型,例如:AudioManager.STREAM_VOICE_CALL、AudioManager.STREAM_SYSTEM等,index为音量大小
    falgs为标志位。
  • 相关阅读:
    SCOI2007 组队
    ZJOI2008 生日聚会
    织梦标签截取指定数目字符
    HTML特殊符号对照表
    DedeCMS让{dede:list}标签支持weight权重排序
    PHP 5.4 中经 htmlspecialchars 转义后的中文字符串为空,DeDeCMS在PHP5.4下编辑器中文不显示问题
    把图文内容载入微应用中
    织梦安装错误
    dedecms创建或修改目录失败
    安装phpmyadmin
  • 原文地址:https://www.cnblogs.com/xingmeng/p/2424897.html
Copyright © 2011-2022 走看看