嗨,我是android开发的新手,我正在尝试制作游戏。我目前想为我的游戏禁用声音效果,可以在首选项 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);
}
}
但是,当我这样做时,声音效果不会关闭。
最佳答案
如果您使用的是默认的SharedPreferences
,则只需执行以下操作即可:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
nixonMode=prefs.getBoolean("nixonmode", false);
关于android - 关闭声音效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6726647/