Should Singleton Pattern Be Used For Android Mediaplayer
I am a newbie to Android and currently learning the Android SDK. I am writing a very simple application that will just play various sounds upon interacting with widgets. I am using
Solution 1:
It is not advisable , as you can see from the extract, to keep an object of MediaPlayer as a singleton. Mainly because valuable resources such as hardware could be kept locked as long as you have a media player object in any of the states other than the END state. Also when you call release(), the object cannot be reused. You would need a new instance. I think the android team wants the developers to create objects when needed and release it when done.
Post a Comment for "Should Singleton Pattern Be Used For Android Mediaplayer"