Stop MediaPlayer service when app goes in Background

前端 未结 5 1095
不思量自难忘°
不思量自难忘° 2020-12-10 21:25

I have a media player service that plays music in the background of my app throughout activities like :

public class Music extends Service {
MediaPlayer play         


        
5条回答
  •  粉色の甜心
    2020-12-10 21:57

    Have you implemented onDestroy()? If not, I believe that might be the solution - and you stop your Player or whatever you're using to run the service within onDestroy().

    A service can be stopped by calling its stopSelf() method, or by calling Context.stopService().

提交回复
热议问题