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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:39:13+00:00 2026-05-25T01:39:13+00:00

Just after a quick wait command that will make my application stop, for say

  • 0

Just after a quick wait command that will make my application stop, for say 10 milliseconds, so that it’ll look like it’s animating stuff (in my case a ball).

    public class PiranhaDrop extends Activity
    {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    FrameLayout main = (FrameLayout) findViewById(R.id.main_view);
    main.addView(new Drawing(this,0,0,0));
    int MyLoop=0;
    while(MyLoop<100)
    {
        main.addView(new Drawing(this,MyLoop,10,10));
        synchronized(this){wait(10);}
        //try{Thread.sleep(WaitTime);} catch (InterruptedException e){}
        MyLoop=MyLoop+1;
        main.setOnTouchListener(new View.OnTouchListener()
        {
            public boolean onTouch(View v, MotionEvent e)
            {
                float x = e.getX();
                float y = e.getY();
                FrameLayout flView = (FrameLayout) v;
                flView.addView(new Drawing(getParent(),x,y,25));
                return false;
            }
        });
    }
}

}

As you can see, just after the loop begins I’ve tried a few things (the WaitTime refers to a long that I got rid of, it didn’t work) – neither of which have worked.

Thanks.

  • 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-25T01:39:13+00:00Added an answer on May 25, 2026 at 1:39 am

    The proper way to wait is this:

    try
    {
        Thread.sleep(10);
    }
    catch (Exception e){}
    

    However, note that this will run on the UI thread.
    For 10ms there is no real problem and it’s the preferred way to wait… But for longer periods it will result in an ugly dialog to your users saying your application is not responding.

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

Sidebar

Related Questions

I have a program that writes to a FILE *cgiOut and just after it
After searching online, the best solution I've found so far is to just make
I'm getting this error after trying to appendChild to an element that was just
Folks, I just have a quick question about updating my app after it is
Just dipping my toes into Linq2sql project after years of rolling my own SQL
I just went through some MVC tutorials after checking this site out for a
I'm just getting back into C++ after a couple of years of doing a
I just purchased C++ GUI Programming with Qt4 and after reading the code samples
I just found /n softwares free Powershell NetCmdlets, and after playing with them I
I'm after some good tips for fluent interfaces in C#. I'm just learning about

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.