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

  • Home
  • SEARCH
  • 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 9240541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:12:25+00:00 2026-06-18T08:12:25+00:00

I have some confusion with android service As per the documentation It will keep

  • 0

I have some confusion with android service
As per the documentation
It will keep on running in the background on main thread . It doesn’t run in a different thread.

My doubt is what is the meaning of keep on running in background . Will it execute the onStartCommand() again and again. I am really very confused with this line (Keep on running in background )

if it will not execute onStartCommand again and again then what is the benefit of Keep on running and if it executes onStartCommand again and again then it is using cpu more and more

Line which confused me is highlighted in the image please have a look
enter image description here

  • 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-06-18T08:12:26+00:00Added an answer on June 18, 2026 at 8:12 am

    As already noted in a comment, for your particular purpose (monitoring a setting, here: volume), you can follow a non-polling approach which is described e.g. here: Is there a broadcast action for volume changes?

    In general, on a modern (though not perfect) environment like Android, there’s almost never a reason to actively poll something, because nobody could afford wasting so much resources, and also, you’ll always risk to miss events, so you’d be tempted to poll more frequently — this is a race which your implementation is always going to lose.

    Once more, the following statements are plain wrong:

    • A Service runs on your app’s main/UI thread. If you think this is the case then you need to read about the android:process attribute of the manifest’s activity tag. Also. even if you do not let your service run in a separate process, the phrase a service runs on your app’s main/UI thread suggests that your main/UI thread gets blocked by your service. Of course, hopefully nobody leaves iot art that; it’s easy to just process the service’s events on your app’s main/UI thread and delegate the tasks to worker threads, which is what every sane implementation should do.

    • With START_STICKY, you can ensure that your service will always be running after it got started. Of course, this is naive and means that whoever claims this has not completely understood the meaning of this flag in conjunction with the description of the process lifecylce for Android Services. Quote: Note this means that most of the time your service is running, it may be killed by the system if it is under heavy memory pressure. If you read the section, you will know that Android is going to kill the process with your running service at any time without notice if it needs memory for another task with higher priority and your service is not related to an app which the user currently looks at. In other words, if the system is low on memory and the user opens a spreadsheet which requires most of the system’s memory, then the background internet radio media player and all fancy stuff is likely to get killed, period.

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

Sidebar

Related Questions

I have some confusion regarding where you put regular java code in an android
I have some confusion about the life cycle of native code in Android aps.
I have some confusion when looking at how interrupt handler(ISR) is run. In Wiki
I have some confusion regarding reading a word from a byte array. The background
I have some confusion about when to use the self keyword during ivars assignment,
Hello everyone, I have some confusion regarding some Win32 API data types and macros
i have a coldfusion cfc and some methods in it. MethodA will return a
In Android, I have some code to check whether the user has GPS switched
I have some confusion regarding how the frame size bytes should be coded/decoded for
I have some confusion with the function monad. The function monad is defined as

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.