music pause when app killed when using service

后端 未结 3 1590
無奈伤痛
無奈伤痛 2021-01-29 00:57

I am using a Service class to play music in the background. While I am displaying the notification bar on top, there is issue in my app. When I kill the app, the mu

3条回答
  •  执笔经年
    2021-01-29 01:13

    According to: https://developer.android.com/reference/android/app/Service.html Change

    START_STICKY
    

    to

    START_NOT_STICKY
    

    EDIT:

    The issue with music stopping for a while is connected with the fact that you run app and service in the same process. And 'killing app' means stopping the whole process bound to it. What you need to do is to run your service in seperate process:

    Start a service in a separate process android

提交回复
热议问题