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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:38:10+00:00 2026-06-10T15:38:10+00:00

I have a timer which runs continously. When I press the BACK button I

  • 0

I have a timer which runs continously. When I press the BACK button I made a dialog to appear where you can quit from that intent or go back and cointinue the timer what has been stopped by the BACK button. Well if I click on the contimnue, the onResume() method makes the timer continue and it works good. But, if I press the back button when the dialog is on the screen I want the timer to go on just like if I press the Continue on the dialog. But instead, I press the back button and nothing happens, the timer is stopped and it is not good for me since some of my methods only works if the timer is going or it is stopped by the dialog. But if there is no dialog and the timer is stopped numerous potential errors can happen. So how can I stop the user to press the back button when the dialog is on the screen?
I tried something like this:

if ((keycode==back) && a=0 ) {... a=1 , onPuase()}  // dialog comes in onPause() just happened
else ((keycode==back) && a=1 ) {... a=0, onResume()}  //I want onResume() to happen here  

But it is not good. The dialog appears on the first Back button then it disappears on the second Back (nothing happens here). The timer is still stopped here however the third back button starts the timer. So there is an unecessary Back which can cause troubles since the useres wont know that they have to press it again…

  • 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-10T15:38:12+00:00Added an answer on June 10, 2026 at 3:38 pm

    A few advices:

    1. Do not call onResume/onPause manually, only system should make it. Else you’ll have unexplainable issues on various devices.
    2. You really want to use OnDismissListener ( http://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html ). As starting from ICS, dialog can be dismissed not only by pressing Back key, but also by tapping somewhere on screen, outside the dialog.
    3. If you want to prevent dismissing the dialog by “back” and “tapping out of dialog” – use setCancellable(false) http://developer.android.com/reference/android/app/Dialog.html#setCancelable(boolean) for the dialog.

    Good luck

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

Sidebar

Related Questions

How can i have timer which runs for every 5 secs continously. below is
I have some javascript which runs a timer that animates something on the website.
I have some code which runs in a timer, but I would like to
I have a service which contains a Timer and TimerTask for receiving data from
Suppose we have a timer which runs every 10 minutes. What if the cycle
Not sure why this isn't working. I have a timer defined, which runs a
I have an application that runs many threads. Each thread should have a timer
So I have a python script that runs a loop in which it calls
I have a windows service that runs a method when the services main Timer
I have an application which runs a timer to check for idle time and

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.