Created a simple audio player for Android in Android Studio that plays mp3 files from a remote server.
The application can run in the background.
My Activity also launches Service , which is displayed in Notifications as a layout with a Play / Stop button.
Everything works in the background without problems, until I begin to actively use other applications (I open several new applications at once, load data into them, etc.).
As a result, after some time, my application terminates, and the OnDestory event is not OnDestory on the Activity .
The size of the RAM in my device is 1G. I suspect that the system is killing my application due to lack of resources.
Question: if the problem is exactly this, then how to solve it? How to prevent the system from killing my application when there are not enough resources?
startForegroundservice? - Vladyslav MatviienkostartForeground. Thanks for the help! I will try - Ivan Myasnikov