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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:46:12+00:00 2026-06-16T16:46:12+00:00

In a game I am developing I want to create a delay. The delay

  • 0

In a game I am developing I want to create a delay. The delay am I makeing is using a handler with this code:

handler.postDelayed(new Runnable() {
        public void run() {
               animationDrawable.start();

                }
        },theDelay);

The problem is that I got a pause button that is going to make everything stop, and not do anything until you resume again. For now it is running even though the gameplay is paused. I got a boolean that is changed when I want to pause the activity.

I have searched for solutions using a Thread, TimerTask and Handler, but for everyone of these I have seen warning about that non of these is safe to use.

How can I pause and resume this “countdown” in a secure way, and without haveing to start it all over again when resuming?

  • 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-16T16:46:13+00:00Added an answer on June 16, 2026 at 4:46 pm

    How can I pause and resume this “countdown” in a secure way, and without having to start it all over again when resuming?

    1. save the start time when you start the handler like this – startTime = System.currentTimeMillis();
    2. inside the onPause save that time pauseTime = System.currentTimeMillis(); and cancel the hendler
    3. inside onResume recreate the event with the pauseTime - startTime
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I'm new in Android Developing. I want to create an easy game using
I am developing visual game level editor in C++. For this I want reflection(RTTI)
I am developing a game with WPF technology. I want to add new Features
I want to start this as a hobby in developing a desktop game. I
I want to develop a game using Andengine and i am new to game
I'm developing a small j2me game and i want to create a menu for
I am developing a game using libgdx framework. I want to raise a dialogue
I am developing an iPhone game using OpenGL ES. I want to move the
I'm developing fairly simple 2D game for android using OpenGL ES. I want it
I am developing one 2d game using cocos2d framework, in this game i am

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.