I currently want to disable sound effects for my game, which I toggle on or off in a preferences activity.
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);
}
}
When I do this however, the soundeffects don't turn off.
If you're using the default SharedPreferences
, you should be able to do it by simply doing something like this:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
nixonMode=prefs.getBoolean("nixonmode", false);
精彩评论