开发者

Heap size overflow issues with sound clips

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开发者_JAVA技巧 menu or would this bring up a whole new set of issues?)?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜