How can I make my app pause for 5 seconds?


Last Updated:

  1. GIR

    GIR Well-Known Member This Topic's Starter

    Joined:
    Feb 14, 2010
    Messages:
    96
    Likes Received:
    10
    Hello again,

    Ive been trying many combination of examples (yes - im still learning), but so far ive been unable to make my program pause for 5 seconds.

    My goals is this:

    Display a picture for 5 seconds, then display buttons.

    The only thing that is different from other examples ive seen is that the content is produced dynamically on the screen, no xml is used.

    Can anyone please help?

    Ive been trying different examples, but none seem to simply pause the program without making the app force close.

    The current method im trying is:
    Code (Text):
    1.  
    2. int pause = 15;
    3.         int startTime = 0;
    4.         while ( System.currentTimeMillis() <= startTime + (pause * 1001)){
    5.                        if (System.currentTimeMillis() >= startTime + (pause * 1001)) {
    6.                        }}
    7.  
    Thanks in advance,
    GIR
     

    Advertisement
  2. miXer

    miXer Well-Known Member

    Joined:
    Aug 12, 2010
    Messages:
    313
    Likes Received:
    51
    You can try using Thread.sleep(5000) like this:
    try { Thread.sleep(5000); }
    catch (InterruptedException ex) { android.util.Log.d("YourApplicationName", ex.toString()); }
     
  3. id0001

    id0001 Well-Known Member

    Joined:
    Apr 20, 2010
    Messages:
    142
    Likes Received:
    23
    GIR likes this.

Share This Page

Loading...