Question

I'm creating an Android app that involves multiple short sound clips. At the moment, I'm using SoundPool to load my sound clips once a 2nd activity is begun by the menu activity. The problem I seem to be having is that once this secondary activity begins, the loading of the sound clips causes multiple heap size overflows and then after a bit the activity actually loads (the emulator never gives an error or a force quit). Would using the MediaPlayer help me here and keep these heap size overflows from occuring?

Also, at the moment, the menu activity starts the 2nd activity waiting for a result (using the startActivityForResult() function). Does this mean that the menu activity is being held in memory as well as loading the 2nd activity into memory? If so, could I help my memory issues by calling finish() on the menu activity once the 2nd one is started (then restarting the menu activity when the user wishes to go back to the menu or would this bring up a whole new set of issues?)?

Was it helpful?

Solution

Yes, soundpool will keep all the sounds in memory. A single instance of media player would probably be all you need see here. You should do this and your memory issues should go away without having to go to any extreme measures.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top