Android Question Running background service even in sleep mode

Discussion in 'Android Questions' started by Reids, May 13, 2015.

  1. Reids

    Reids Member Licensed User

    Hello I just creating chat apps, the apps work fine when activity still active, or when user clicked back button message still can be arrived, but if user kill apps with taskmanager (holding home button and swipe it) the apps is killed and service won't start again so message won't arrive anymore

    how I can handle this?

    summary :
    ** Activity (main) Create, isFirst = true ** >>> message still can arrived
    ** Activity (main) Create, isFirst = false** >>> message still cannot arrived


    I tried to use
    Code:
    Sub Activity_Pause (UserClosed As Boolean)
        
    If UserClosed Then
        
    Log("main is paused")
        
    StartService(PushService)
        CallSubDelayed(PushService, 
    "ReconnectTimer_Tick")
        Awake.ReleaseKeepAlive
        
    End If
    End Sub
    service still not executed :(
    anybody can help?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    On newer versions of Android, the app will not start after the user explicitly killed it (unless the user has explicitly started it again).

    Call Service.StartForeground. It may prevent the process from being killed.
     
    Reids likes this.
  3. Reids

    Reids Member Licensed User

    Hi erel, sorry about my post before on other thread, I finally solve the problem, it is because some parameter couldn't be passed from activity to service
    now the apps work well thank you very much!
     
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