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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:52:40+00:00 2026-05-20T08:52:40+00:00

I’m using alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 0, DURATION, broadcast); To schedule an repeating task that should only

  • 0

I’m using

alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 0, DURATION, broadcast);

To schedule an repeating task that should only be executed if the device is not asleep. As I understand the API on the AlarmManager the intent will be called once the device wakes up from sleep.

Now when is an Android device asleep? For testing I set the duration to two minutes and connected the device to my machine. Now I’m watching logcat and every two minutes it will spit out my debug message.

I always thought that an deactivated screen means that the devices starts sleeping.
Or is my looking at the debug output preventing the device from sleeping?
I also disconnected the USB connection and looked at the log after half an hour and I could see a call to my timer code even if the display was dark for more then 15 minutes.

How can I verify from which time the command is not executed anymore and what asleep refers to in the AlarmManager documentation? Is there a way to see from the logcat output when the device started sleeping?

  • 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-20T08:52:41+00:00Added an answer on May 20, 2026 at 8:52 am

    Device is asleep when there is not running application that prevents it from sleeping. So:
    1. The screen is off (while it’s on there is always some running app, e.g.Launcher)
    2. There is no running service (e.g. music, downloads) – no CPU locks.

    AlarmManager wakes device from sleeping, runs what is to run. It’s critical e.g. to ends a service that was created in broadcast receiver from alarm to let the device fall asleep again. If you do sth longer and important in the background you should acquire CPU lock for your app to prevent it from being killed by Android OS.

    What do you exactly mean by “How can I verify from which time the command is not executed anymore”? What command?

    From JavaDoc:

    Registered alarms are retained while
    the device is asleep (and can
    optionally wake the device up if they
    go off during that time), but will be
    cleared if it is turned off and
    rebooted.

    So OS hold all alarms, device can be waken up by the alarm that goes while it is sleeping. Alarms are dropped after reboot (you should keep them in DB and restore them after reboot).

    “Is there a way to see from the logcat output when the device started sleeping?”
    As I know there isn’t, I can only see sth like that when screen goes off:

    *** set_screen_state 0 from “power” tag

    IMHO you shouldn’t bother about sleep mode, just make your app “good Android citizen” by handling screen off and on intents (Intent.ACTION_SCREEN_OFF) if needed, finishing services ASAP, releasing resources (network, GPS, CPU) ASAP, using inexact alarms, download manager, and all good staff brought by OS. I believe that Android handles CPU sleeps transparently.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping 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.