Skip to content Skip to sidebar Skip to footer

App Stops Working When Mediaplayer Is Stopped In Service Class

I am making a media player which plays music using an URL. I implemented a foreground service and also a notification. They are working fine. The problem is when I implement .stop

Solution 1:

Remove the word MediaPlayer from inside onStartCommand(). You declared a local variable with the same name as a member variable, causing the member variable to be "shadowed". That left it uninitialized, which caused an NPE in your onDestroy().


Post a Comment for "App Stops Working When Mediaplayer Is Stopped In Service Class"