Forum Xamarin.Forms

Android background service closes when I close application. How i doing wrong?

I trying to make service, which leave running in background while I close the application. I used the example from:

and I removed StopService(new Intent(this, typeof (SimpleService))); from Activity1.cs , but the service stopping when I close Main activity. How I doing wrong? Please help me.

Best Answer


  • CedGabrangCedGabrang USMember ✭✭

    @lakewik how did you started your service?

  • lakewiklakewik USMember

    @CedGabrang StartService(new Intent(this, typeof(SimpleService)));

  • lakewiklakewik USMember

    @CedGabrang Big thanks! The return StartCommandResult.Sticky; solved my problem, and I fortuity started the application without debugger and the service now running in background while i close MainActivity. But with debugger the service closing with MainActivity, but i think it is normal.

  • HarbHarb USMember ✭✭

    How do you combine the OnStartCommand Sticky with an AlarmManager that runs periodically?

  • jackrajjackraj USMember ✭✭

    Hi all,
    When the application is locked state means background services running. I have attached the screenshot to this message below

    but reboot time error occurred but services run after some time I have mentioned screenshot below

Sign In or Register to comment.