Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>using onResume() and a Handler, the easy and clean way</h2> <p>Have you tried to put this...</p> <pre><code>// Intent to jump to the next activity Intent intent= new Intent(this, NextActivity.class); SystemClock.sleep(2000); //NOTE before the start of the next activity this.startActivity(intent); </code></pre> <p>...in onResume();</p> <p>As far as I know, it's not the idea that the Activity is displayed right when onCreate() is called. But onResume() gets always called and as far as i know everthing should be displayed by then. If you want to show it only once, make your flag for it. see: <a href="http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle" rel="nofollow">Activity lifecycle</a></p> <p>But anyway, what you're doing it the wrong way ;) use a Handler, Thread or similar for this</p> <p>Other solutions:</p> <ul> <li>Why not display an ImageView infront of everything and just hide it after 2s? you could just use a <code>Handler</code> for your delay. Or even use transparency to make a fancy fadeout. Look at <code>ImageView setAlpha(...)</code>.</li> <li>Why not use a <code>Handler</code> instead of the <code>sleep(...)</code>. IMHO <code>sleep(...)</code> could result in a 'Application Not Responding'</li> </ul> <p>this code should to the job:</p> <pre><code>Handler mHandler = new Handler(); class MyTask implements Runnable{ public void run(){ //start next activity or fadeout ImageView or ... } } </code></pre> <p>now call in onResume:</p> <pre><code>mHandler.postDelayed(new MyTask(), 100); //or any other Runnable </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload