Reputation: 2214
Well , I use SoundPool for onClick on ImageView sounds and some of them starts another Activity. Like this :
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()){
case R.id.main_menue_status:{
button_click.play(button_clickID, 1,1, 0, 0, 1); //this is SoundPoool's play
Intent intent=new Intent(context,MainMenueActivity.class);
startActivity(intent);
finish();
}
other activities has same ImageViews(actually, buttons) to navigate through the app. And all the time I use finish(); to prevent creating millions of copies of activities. So after about 30 SoundPool's plays sound stops playing at all.
My guess is that's because I finish() Activity before sound complete it's playback so somehow system stop playing any SoundPool at all.
Any advice?
UPD : Log :
12-01 19:04:49.797: E/AudioTrack(19981): AudioFlinger could not create track, status: -12
12-01 19:04:49.797: E/SoundPool(19981): Error creating AudioTrack
Upvotes: 0
Views: 1515
Reputation: 39191
The "status: -12", I believe, is an Out of Memory error. Also, calling finish()
in an Activity is not a guarantee that the Activity will immediately finish and release resources.
Since you have several Activities and several SoundPools, I would recommend creating the SoundPool and loading your sound resources in the Activity's onResume()
method, and then unloading the resources and releasing the SoundPool in the onPause() method.
Upvotes: 2