I am trying to build my own soundmanager which is a singleton. I have 3 activities in my application:
MenuActivitie |+GameActivitie |+Settingsactivitie
In settings the user have the possibility to turn sound on an off. When I end the game and restart there is no sound is playing. This is my code... Where is my mistake?
package com.jb.sound;
import com.jb.R;
import android.content.Context;
import android.media.MediaPlayer;
public class SoundManager {
static MediaPlayer mp;
private static SoundManager instance = null;
boolean play = false;
static Context _context;
private SoundManager(Context context){
_context = context.getApplicationContext();
mp = MediaPlayer.create(_context.getApplicationContext(),R.raw.uhr);
}
public static SoundManager getInstance(Context context){
if(instance == null ){
instance = new SoundManager(context);
}
return instance;
}
public void soundStart(){
mp.start();
}
public void soundStop(){
mp.stop();
}
public boolean musicIsPlaying(){
return play;
}
}