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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:19:31+00:00 2026-05-15T16:19:31+00:00

I am looking to create timed events which trigger UI changes (like a Toast)

  • 0

I am looking to create timed events which trigger UI changes (like a Toast) on Android. I already know you can do this with a Handler object’s postDelayed(runnable, timeDelay) method (see this page for a great example).

Here is the twist: I also need to be able to pause and resume the countdown for these events. So when a user pauses the on-screen timer it also pauses the countdown before each of these events trigger.

One approach that came to mind was to create a Handler object on a new Thread (not the UI thread) and queue up my events using postDelayed; then I would pause or resume this entire Thread‘s execution using this method as needed. The main problem here is figuring out how to make the events run on the UI thread after they have been triggered.

The only other way I can think of would be to check every second that the timer ticks against a list of all my events (brute force) on the UI thread, which is very messy.

If anyone has any thoughts on this or solutions, that would be great!

  • 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-15T16:19:31+00:00Added an answer on May 15, 2026 at 4:19 pm

    If all events need to be paused the same amount of time, you could keep track of how much pause time accumulated and, on the handleMessage, re-post using another postDelayed with that delay time.

    Some logic would need to be added to make sure you delay them all the proper amount. For example, if a new event was added into the queue while the game was paused, you wouldn’t want to re-post it delayed by the entire pause amount.

    You could combine your idea (a queue of events with desired start times). Update that start time when the pause ends. Use a single event that is “processQueue” – set it to only fire when you think the next event should happen. If the time the next event should happen is delayed due to a pause, you can remove the “processQueue” event and re-post it.

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

Sidebar

Ask A Question

Stats

  • Questions 460k
  • Answers 460k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Atomic properties are necessary in a reference counted multi threaded… May 15, 2026 at 11:37 pm
  • Editorial Team
    Editorial Team added an answer It'll certainly work, and that approach is used in a… May 15, 2026 at 11:37 pm
  • Editorial Team
    Editorial Team added an answer The problem is that you're building you application to use… May 15, 2026 at 11:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.