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