Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 关闭声音效果_Android_Audio_Options - Fatal编程技术网

Android 关闭声音效果

Android 关闭声音效果,android,audio,options,Android,Audio,Options,大家好,我是android开发新手,我正在尝试开发一款游戏。我当前想禁用游戏的音效,我可以在“首选项”活动中打开或关闭该游戏 public static void initSounds(Context theContext) { if(OptionsMenu.getSounds(theContext)) { mContext = theContext; mSoundPool = new SoundPo

大家好,我是android开发新手,我正在尝试开发一款游戏。我当前想禁用游戏的音效,我可以在“首选项”活动中打开或关闭该游戏

public static  void initSounds(Context theContext)
    {

        if(OptionsMenu.getSounds(theContext))
        {
             mContext = theContext;
             mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
             mSoundPoolMap = new HashMap();
             mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
        }
    } 

但是,当我这样做时,音效不会关闭

如果您使用的是默认的
SharedReferences
,只需执行以下操作即可:

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    nixonMode=prefs.getBoolean("nixonmode", false);