Android service close if app closes

FrankGuerraFrankGuerra ✭✭USMember ✭✭

hi guys i'm trying to do an android service for my app and i'm facing this issue, i've been looking for information about it and found that i need to use StartCommandResult.Sticky option for the service to not get closed, but it is not working here's the piece of code i'm using:

    protected override StartCommandResult onStartCommand(Intent intent, StartCommandFlags flags, int startId){
        var t = new Task(() => {



        return StartCommandResult.Sticky;

and this is how i've been calling it in my activity

protected override void OnCreate(Bundle bundle){
    new Task(StartService).Start();

void StartService(){
    var intent = new Intent(Application.Context, typeof(MyService));

but didin't work =(
can anyone help me, for you guys to know i've been trying things the whole day believe me


  • Xami3Xami3 ✭✭✭ PKMember, University ✭✭✭
  • FrankGuerraFrankGuerra ✭✭ USMember ✭✭
    edited February 2018

    @Xami3 it's not a bound service, i want it to keep running the service even if i kill the app that started it, that's why i dont understand, maybe i'm missing something important but i don't know what it is, btw the service is well decorated with the service attribute and extending from service class aswell

  • FrankGuerraFrankGuerra ✭✭ USMember ✭✭

    Does anyone else has information about this pls?
    my head is suffering for this

  • frakafraka ✭✭ TZMember ✭✭

    Hello @FrankGuerra , probably I am late for this but to successfully implement that, you must set the service as IsolatedProcess.
    Something like this...

            (Name= "com.Location.App.SimpleService", 
            IsolatedProcess = true, 
            Icon = "@drawable/icon", 
            Process = "ProcessThatRunsTheService", 
            Label = "SimpleService")]

    That, service will run even when app is closed.

  • FrankGuerraFrankGuerra ✭✭ USMember ✭✭
    @fraka not you're not late my friend i'm still figthing with that, let me try what you suggest and I will notice you if that works, thanks for your response
Sign In or Register to comment.