Android service stop working after I run another app/game

Roman Holic

do you have any idea what can bee root cause of my Android app service stop working when i run random another app/game?

I do not have code available, i just need causes.

Thank you.

blockwala

Service runs in your app process. If your app is garbage collected, the service will stop until:

  • You start the service in new process via manifest file declaration
  • You make the service sticky (recommended).

go ahead and research above two and let me know if you would like more explanation or code

UPDATE

If you see official documentation of Service, Google clearly explains why and when service will be destroyed. What is useful in your scenario:

A started service can use the startForeground(int, Notification) API to put the service in a foreground state, where the system considers it to be something the user is actively aware of and thus not a candidate for killing when low on memory. (It is still theoretically possible for the service to be killed under extreme memory pressure from the current foreground application, but in practice this should not be a concern.)

using startForeground will ensure your service keeps running in the same process. some pointers:

  • A service with attached client will not be destroyed even on low memory scenarios
  • A service will be killed in low memory scenarios, regardless of the process. Running in a different process is better but does not guarantee it won't be destroyed by system.
  • Don't use system.exit(0) to end your app. call finish() on activity.
  • Starting sticky service just ensures that service is restarted when memory is freed.

hope it helps!

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

how to start service and stop it at another activity in android

分類Dev

Android is killing my foreground service after Force stop my package

分類Dev

android : stop a sticky service

分類Dev

docker unrecognised service when i run this command sudo service docker stop

分類Dev

Scheduling starting a service after another service

分類Dev

Playing Sound in Java after a while stop working

分類Dev

Android-通知pendingIntentto Stop Service

分類Dev

Android-通知pendingIntentto Stop Service

分類Dev

How to stop Android service when app is closed

分類Dev

How to Start Service and Stop Service Based on Time Interval in android

分類Dev

Can't stop foreground service stopSelf() and stopForeground(true) not working

分類Dev

ionic3/angular 4 : Injecting a service in another service not working

分類Dev

Clear boost::asio::io_service after stop()

分類Dev

Docker container will automatically stop after "docker run -d"

分類Dev

Router stop working after define Resolver with ngrx store injected

分類Dev

Slideshow stop working after adding second slide show

分類Dev

node.js serialport events stop working after reconnecting to port

分類Dev

Luarocks stop working after updating from 2.0.2 to 2.2.0 for windows

分類Dev

Why do I get “file is used by another process” errors when I run the project within Android Studio 3.6.1?

分類Dev

How do I STOP an Azure BizTalk Service without deleting it?

分類Dev

How to stop START_STICKY android service from activity

分類Dev

Android Service stops after the app is killed

分類Dev

App crashes after I run the script

分類Dev

NativeScript background service stops working after app closes

分類Dev

CORS not working after I copied the instance

分類Dev

i3-Gaps | Not working after install

分類Dev

Do I need to disconnect an Oscillator AudioNode after stop it?

分類Dev

Android - AlarmManager is not working after app is closed

分類Dev

Android - AlarmManager is not working after app is closed

Related 関連記事

  1. 1

    how to start service and stop it at another activity in android

  2. 2

    Android is killing my foreground service after Force stop my package

  3. 3

    android : stop a sticky service

  4. 4

    docker unrecognised service when i run this command sudo service docker stop

  5. 5

    Scheduling starting a service after another service

  6. 6

    Playing Sound in Java after a while stop working

  7. 7

    Android-通知pendingIntentto Stop Service

  8. 8

    Android-通知pendingIntentto Stop Service

  9. 9

    How to stop Android service when app is closed

  10. 10

    How to Start Service and Stop Service Based on Time Interval in android

  11. 11

    Can't stop foreground service stopSelf() and stopForeground(true) not working

  12. 12

    ionic3/angular 4 : Injecting a service in another service not working

  13. 13

    Clear boost::asio::io_service after stop()

  14. 14

    Docker container will automatically stop after "docker run -d"

  15. 15

    Router stop working after define Resolver with ngrx store injected

  16. 16

    Slideshow stop working after adding second slide show

  17. 17

    node.js serialport events stop working after reconnecting to port

  18. 18

    Luarocks stop working after updating from 2.0.2 to 2.2.0 for windows

  19. 19

    Why do I get “file is used by another process” errors when I run the project within Android Studio 3.6.1?

  20. 20

    How do I STOP an Azure BizTalk Service without deleting it?

  21. 21

    How to stop START_STICKY android service from activity

  22. 22

    Android Service stops after the app is killed

  23. 23

    App crashes after I run the script

  24. 24

    NativeScript background service stops working after app closes

  25. 25

    CORS not working after I copied the instance

  26. 26

    i3-Gaps | Not working after install

  27. 27

    Do I need to disconnect an Oscillator AudioNode after stop it?

  28. 28

    Android - AlarmManager is not working after app is closed

  29. 29

    Android - AlarmManager is not working after app is closed

ホットタグ

アーカイブ