Does Android MediaPlayer set to null when released?

Looking at an example of how to release an Android MediaPlayer instance in the official doc, it says that we should zero out the object after it's released:

This is how you should free and then minimize your MediaPlayer:

mediaPlayer.release();
mediaPlayer = null; // <-- instruction I am asking about.

      

Is it really necessary? If so, why?

Source: https://developer.android.com/guide/topics/media/mediaplayer.html#releaseplayer

+3


source to share


1 answer


null

means a GC mark that can "collect" this object.



+2


source







All Articles