July 2015
Beginner to intermediate
600 pages
18h 59m
English
The app works, but you still have some cleanup to do. To be a good citizen, you should clean up your SoundPool by calling SoundPool.release() when you are done with it. Add a matching BeatBox.release() method.
Listing 19.7 Releasing your SoundPool (BeatBox.java)
public class BeatBox {
...
public void play(Sound sound) {
...
}
public void release() {
mSoundPool.release();
}
...
}
Then, clean it up when you are done with it in BeatBoxFragment.
Listing 19.8 Releasing your BeatBox (BeatBoxFragment.java)
public class BeatBoxFragment extends Fragment {
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
...
}
@Override
public void onDestroy() ...Read now
Unlock full access