How to stop the service when the app is dismissed from recent tasks
@marcbaechinger is already working on this.
Since Jun 27, 2023.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Media3 Version
Media3 1.1.0-alpha01
Devices that reproduce the issue
Pixel 4 API 33 or any device
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
Launch the demo-session app. Play any song.
We have this code here
override fun onTaskRemoved(rootIntent: Intent?) {
If (!player.playWhenReady) {
stopSelf()
}
}
The question is how to close the app when I swipe the app from recents?
If I remove this check if (!player.playWhenReady) and call stopSelf() app is leaking. App is not visible in recents but android studio profiler shows that it is running and the service still takes memory.
Adding player.stop() before stopSelf() in onTaskRemoved(rootIntent: Intent?) also not helping.
So I'm looking for a solution to close the app and free all resources when swiping from recents or clicking on custom button in notification.
One more question. When killing the app by
val id = Process.myPid()
Process.killProcess(id)
sometimes the service restarts itself. Why does it happen?
Expected result
I need a way to close the app and free memory in both cases when Exoplayer is playing/paused.
Actual result
Demo app release resources only when exoplayer is paused. !player.playWhenReady
Media
Bug Report
- You will email the zip file produced by
adb bugreportto dev.exoplayer@gmail.com after filing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.