Background music Android

后端 未结 9 1581
夕颜
夕颜 2020-12-03 01:57

Okey, this is my problem. I have one service class where Ive managed to create media player to play music in background all time. Here is code:

package com.t         


        
9条回答
  •  余生分开走
    2020-12-03 02:47

    yes, u should stop the service when u press the home button . In OnPause(){} override method u should stop the music service. And inside the service in OnDestroy() method u please stop the media player. So now,pressing home calls onPause and onPause() -> stops the service and OnDestroy is executed in service and in odestroy() the mediaplayer is stopped and ur problem is fixed.

提交回复
热议问题