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 9264529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:50:59+00:00 2026-06-18T13:50:59+00:00

I have a long running service which responds to multiple BroadcastReceivers (created in code,

  • 0

I have a long running service which responds to multiple BroadcastReceivers (created in code, not manifest). Most of the time the service is running well, but from time to time it gets somehow stopped (the BroadcastReceivers stop to work) – I guess the system pauses it somehow (when I look into the running processes on the device I can clearly see the service is still “runnning”).

I don’t know the right reason why the service is being paused, but I’d like to know whether in these cases the onDestroy() method is called or whether there’s a chance to handle this somehow.

I presume onDestroy() is not being called, because the service is still visible in the Running processes tab. I also have the service return the START_STICKY flag so the system should restart it whenever it’s killed for memory reasons. Also if it is “paused” somehow, is it possible to create a WakeLock for this not to occur?

I know that the best solution would be to put all the BroadcastReceivers into the manifest and create a one shot-service called from their onReceive() methods. However I have chosen to go with the way of long running service because the initialization stage is very intensive it’s better to initialize everything just once.

  • 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-18T13:51:00+00:00Added an answer on June 18, 2026 at 1:51 pm

    onDestroy() will be called only when service is being killed by lack of resources or when you explicitly stop it.

    The service can be “paused” when your phone goes idle (usually when screen is off) because the CPU stops. To make services run always you should use PowerManager.PARTIAL_WAKE_LOCK – but use it wisely because it does not stop your CPU and thus draining the battery. You should never leave your apps running always. Just do what you need holding a WakeLock and then release it.

    http://developer.android.com/reference/android/os/PowerManager.html

    http://developer.android.com/reference/android/os/PowerManager.WakeLock.html

    You can use AlarmManager to “wake” your apps periodically and do something.

    http://developer.android.com/reference/android/app/AlarmManager.html

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

Sidebar

Related Questions

I have a web application which passes long-running requests to a Windows Service on
I have an activity that starts a long-running service which in turn adds an
I have a Windows service which performs a fairly long running task. At the
I have a windows service which spawns off long-running tasks while polling for them.
I have a transactional grails service which is doing some (long running) processing. While
I too have a long running service using plugins and appdomains and am having
I have a long running method which can take a minute. On my local,
I have a service running which periodically checks a folder for a file and
I have an Android app, in which Activities fire long running operations that run
I have a long running Service method (doing business logic) and I would like

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.