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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:24:22+00:00 2026-06-01T11:24:22+00:00

I have a widget that, when pressed, sends a broadcast that starts a CountDownTimer

  • 0

I have a widget that, when pressed, sends a broadcast that starts a CountDownTimer that updates my widget, and at the end plays an alarm. This works beautifully in the emulator.

On my phone, however, it’s a different story. My phone is so resource constrained that my process is killed regularly, which, of course, means that the CountDownTimer no longer updates my widget.

It seems to be that the only way to reliably do stuff in the future is to use the AlarmManager, as this sets a system-level alarm. However, the documentation states, and I agree, that you’re not supposed to use it for ticks. However, since anything else you’re likely to use has the possibility of being shut down arbitrarily, they’re not really giving us much choice.

My question is: is there a way to ensure that a CountDownTimer keeps ticking and finally calls onFinish(), or do I have to simply drop it and switch to AlarmManager, and “misuse” it? Any other options of guaranteeing that the thing ticks and finishes are also welcome.

I should add that I can’t rely on the OS calling onUpdate(), both because it will do so no faster than every 30 minutes, and also because most of the time the widget just does nothing. It’s only when it is clicked that it ticks down every second for a handful of minutes.

  • 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-01T11:24:24+00:00Added an answer on June 1, 2026 at 11:24 am

    What I ended up doing was moving from a BroadcastReceiver to a Service.
    Not just using a dummy service, but having a real service embody what the BroadcastReceiver did previously.

    As this won’t guarantee that my timers won’t get killed, if requested, android will automatically try to restart your service after it’s been killed. In this event, I plan to have some code that will restore the running state from disk and continue.

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

Sidebar

Related Questions

I have a simple widget that plays a sound file when pressed. Right now,
I have a JavaScript widget that is hosted on websites. This widget tracks state
I have a home-screen widget that has an icon that starts/so pose to bring
I have a short audio clip that plays when a button is pressed. I
I have a widget that acts as a launcher on the home screen. How
I have a widget that supposed to call an Activity of the main app
I have a widget that customers buy to put on their site. We're running
Let's say that I have a widget that displays summary information about how many
I have a UI widget that needs to be put in an IFRAME both
I have a jquery widget that get data from a server in another domain

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.