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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:24:01+00:00 2026-06-02T21:24:01+00:00

can anyone tell me why in android.developer documentation they said : just sleep for

  • 0

can anyone tell me why in android.developer documentation they said : just sleep for 30 seconds.

and then put 15 * 1000, which is not 30s it’s only 15 !!

 Runnable mTask = new Runnable() {
                public void run() {
                    // Normally we would do some work here...  for our sample, we will
                    // just sleep for 30 seconds.
                    long endTime = System.currentTimeMillis() + 15*1000;
                    while (System.currentTimeMillis() < endTime) {
                        synchronized (mBinder) {
                            try {
                                mBinder.wait(endTime - System.currentTimeMillis());
                            } catch (Exception e) {
                            }
                        }
                    }

                    // Done with our work...  stop the service!
                    MyAlarmService.this.stopSelf();
                }
            };

Here

  • 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-02T21:24:07+00:00Added an answer on June 2, 2026 at 9:24 pm

    You are seeing one of the pitfalls when documenting code that would be better off with descriptive variable names. My guess is that they forgot to update their comment when changing the value to 15 seconds.

    Personally, I usually introduce a constant variable, e.g.

    private final static int 15_SECONDS = 15 * 1000;
    

    or alternatively use

    private final static int SECONDS = 1000;
    

    and in the code use

    long endTime = System.currentTimeMillis() + 15_SECONDS;
    

    or respectively

    long endTime = System.currentTimeMillis() + (15 * SECONDS);
    

    That way it is both clear what the code does, and it is also clear if I decide to change the values as it is easy to remember to change the variable names.

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

Sidebar

Related Questions

Can anyone tell me which all Intent Actions are there in Android. I couldn't
Can anyone tell me what are the packages available in Android, and which package
I want to develop android based application in c#.Can anyone tell me where can
Can anyone tell me about the below warning refers to in android eclipse. Keybinding
Can anyone tell me how I can display a status message like 12 seconds
Can anyone tell me how to add a boarder to a TableLayout in android,
Can anyone tell me how to make a flexible AppWidgets in Android according to
I am new to Android. can anyone tell me about Android that how can
can anyone please tell me in android, is it possible to access the list
Can anyone tell me how to get the application version in Android?

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.