1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question How to keep service alive

Discussion in 'Android Questions' started by Scantech, Apr 28, 2019.

  1. Scantech

    Scantech Well-Known Member Licensed User

    Im confused with the tutorial. I have 2 services which gets destroyed when app is in background. how do i prevent this from happening?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Scantech

    Scantech Well-Known Member Licensed User

    I added your example in my service (only one of them). I had a timer running every 5 seconds and updating the notification. It is holding and not getting killed. My question, do i need the example in both services or 1 is sufficient. I am concerned the other service might get destroyed? So far both are holding.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    This is not needed.

    One is enough. The foreground service will cause the app to be kept in the foreground state.
    See the last section in this tutorial: https://www.b4x.com/android/forum/threads/automatic-foreground-mode.90546/#content
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice