I have a splash screen for my application that plays an mp3 clip on start up.
I want to give the user the option to disable/enable sound via a settings menu of my app. How can I implement this so that application remembers the user's preference every time they open the app.
Please see my code below for the sound.
public class Splash extends SherlockActivity {
SoundPool sp;
int explosion = 0;
MediaPlayer mp;
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.splash);
sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
explosion = sp.load(this, R.raw.soundfile, 1);
Thread timer = new Thread() {
public void run() {
try {
sleep(5000);
if (explosion != 0)
sp.play(explosion, 1, 1, 0, 0, 1);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent openMenu = new Intent(
"ttj.android.t3w.STARTINGPOINT");
startActivity(openMenu);
}
}
};
timer.start();
}