Make all of your methods and class variables in SoundManager
static (and pass in a Context
for the methods that require one).
I would suspect that you are maybe creating a new instance of SoundManager
in each of your Activities, which would create multiple instances of SoundManager
. Making it statically accessible will mean all Activities are modifying the same variables.
Another note, I don't think you have to have an Activity Context
, so try passing in your application's Context via context.getApplicationContext()
. This will avoid tying the MediaPlayer
object to any specific Activity.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…