2011-07-17 61 views
0

嗨,我是新開發的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); 
     } 
    } 

但是,當我這樣做時,soundeffects不會關閉。

回答

0

如果您使用的是默認SharedPreferences,你應該能夠做到這一點,只需做這樣的事情:

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