Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6546925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:46:03+00:00 2026-05-25T11:46:03+00:00

I want a service which can run in the background until I stop, even

  • 0

I want a service which can run in the background until I stop, even if the component that started it is destroyed and also allows binding to the activities. How it is possible ?

As per android bound services document – there are three ways of creating bound service

  1. Extending Binder class.
  2. Using Messenger.
  3. Using AIDL.

I have created a bound service using messenger (2nd method). Activity is bind to service in its onStart() method and unbind in its onStop() method. Two way messaging (between activity and service) works properly. But problem is that when activity unbinds service, service is destroyed. But I want a service which can run indefinitely.

It is possible as android Services Dev Guide – “Although this documentation generally discusses these two types of services separately, your service can work both ways—it can be started (to run indefinitely) and also allow binding. It’s simply a matter of whether you implement a couple callback methods: onStartCommand() to allow components to start it and onBind() to allow binding.”

I also implement onStartCommand() method in service and return START_STICKY, but it is never called. Looking at the lifecycle callbacks of bounded service in dev guide, there is no onStartCommand() callback method. Then how it is possible to run service until we stop and also allow binding?

I am using eclipse platform in fedora 15 OS.

Any Help…..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:46:04+00:00Added an answer on May 25, 2026 at 11:46 am

    You just need to start it with startService() somewhere. This will prevent it from being stopped automatically when there are no more bindings.

    From the Service documentation, emphasis mine:

    A service can be both started and have connections bound to it. In
    such a case, the system will keep the service running as long as
    either it is started or there are one or more connections to it with
    the Context.BIND_AUTO_CREATE flag.

    As others have pointed out, it could still be killed by Android if resources are needed. You can “prioritize” your Service and make it less likely to be killed if you make it a foreground service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please tell me that as we have a service in android which can run
I want to make a simple service, (which will run in the background) when
I want to write a windows service which the user can schedule. i.e, the
Hi I want to create a WCF service that have login method, which is
I've got an Android app which has a periodic background Service. I want this
Is there any service, or test suite or something which I can run against
I want to run a basic service which shows the status of various other
I want to write an application which has 2 EJBs. This application can run
I want to create a service which will insert provided data into spreadsheet fields
I have a selfhosted WCF service application which I want to deploy by a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.