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?

  • Reproduction happens in service, or in Activity? - Vladyslav Matviienko
  • one
    Look onDestroy of your service, but not activation. You can revive the service in this method - miha_dev
  • By clicking on the Activity, a service is created in which playback starts. - Ivan Myasnikov
  • one
    Then tell me, do you call in the startForeground service? - Vladyslav Matviienko
  • No, I do not use startForeground . Thanks for the help! I will try - Ivan Myasnikov

0