Android Question Service.StartForeground ID value

Discussion in 'Android Questions' started by Michael Gasperi, May 21, 2015.

  1. Michael Gasperi

    Michael Gasperi Member Licensed User

    I've only seen examples of Service.StartForeground where the ID = 1. For example: Service.StartForeground(1,test). Is there something special about the 1? I own a tablet where I have to make the ID = 0 or it will error on the call.
  2. DonManfred

    DonManfred Expert Licensed User

    I dont know id the 0 is allowed as an ID for the notification object (see docu of this object and the ID)
    But if it is allowed then you can use a 0 too if you use the 0 in the definition of the notification object
  3. Michael Gasperi

    Michael Gasperi Member Licensed User

    Setting ID to 0 makes the Service.StartForeground just do nothing. What I'm finding is that I need to NOT set the Icon property for the call to work. I suspect this indicates some stupidity on my part. Any idea what I'm leaving out here?

    Below is the service routine whose sole function is to keep the app from being killed. Every second it updates a clock in the activity.

    Sub Process_Globals
    Dim Notification1 As Notification
    Dim timer1 As Timer
    End Sub
    Sub Service_Create
    'Notification1.Icon = "icon"
        timer1.Enabled = 
    End Sub

    Sub Service_Start (StartingIntent As Intent)
    End Sub

    Sub Service_Destroy
        timer1.Enabled = 
    End Sub

    Sub timer1_tick
    CallSub(Main, "Clock")
    End Sub
  4. Erel

    Erel Administrator Staff Member Licensed User

    What is the purpose of this code? If the activity is visible then Android will not kill the process. If the activity is not visible then CallSub will not do anything.
  5. Michael Gasperi

    Michael Gasperi Member Licensed User

    I was trying to do what you told me in this thread:

    Basically I want an app that keeps a display of some current information 24/7. I've tried putting a KeepAlive(True) in Activity_Resume, but once and a while I find that the phone/tablet is just sitting on the home page like the app had been killed. The solution was supposed to be a Service.StartForeground, but I'm not having luck getting that call to work.
  6. Erel

    Erel Administrator Staff Member Licensed User

    Is the activity always in the foreground? If yes then you don't need a service.

    If no, then you just need a service that calls Service.StartForeground.
  7. Michael Gasperi

    Michael Gasperi Member Licensed User

    Thanks. I'm sure you are right.

    The app must be dying a natural death from some other cause.
  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