zoukankan      html  css  js  c++  java
  • 获取设置多媒体音量和屏幕亮度

    mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
    //得到最大音量
    mMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);  
    //得到当前音量
    mVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);  
    //改变声音
    mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0);
      //得到当前亮度
      mBrightness = getWindow().getAttributes().screenBrightness;  
      //调节屏幕亮度
      WindowManager.LayoutParams wlp = getWindow().getAttributes();
      wlp.screenBrightness = mBrightness + percent;
      if(wlp.screenBrightness > 1.0f){
          wlp.screenBrightness = 1.0f;
      }else if(wlp.screenBrightness < 0.05f){
          wlp.screenBrightness = 0.05f;
      }
      getWindow().setAttributes(wlp);  
  • 相关阅读:
    strncat_s
    资源编译器 (.rc) 文件
    C++ Namespace 详解
    Structure Definitions
    SetParent
    C++笔记(1)explicit构造函数
    .def
    tellg()和tellp()
    Data Groups
    Messages
  • 原文地址:https://www.cnblogs.com/wenhui92/p/6242449.html
Copyright © 2011-2022 走看看