Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't use a application context. To know when to use activity context and application context pls check the link below especially the answer by commonsware</p> <p><a href="https://stackoverflow.com/questions/7298731/when-to-call-activity-context-or-application-context">When to call activity context OR application context?</a></p> <p>I tested your code in the post. It works on my device samsung galaxy s3. Only Change i made was having a imageview in the RelativeLayout and set the image for the same in onCreate(). I also used a activity context. Other than that your code is fine. </p> <p>Splash screen using handler </p> <pre><code>public class Splash extends Activity { private static final int SPLASH_TIME = 2 * 1000;// 3 seconds delay @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); ImageView iv= (ImageView) findViewById(R.id.imageView1); iv.setBackgroundResource(R.drawable.afor); try { new Handler().postDelayed(new Runnable() { public void run() { Intent intent = new Intent(Splash.this, MainActivity.class); startActivity(intent); Splash.this.finish(); } }, SPLASH_TIME); } } catch(Exception e){} } @Override public void onBackPressed() { this.finish(); super.onBackPressed(); } } </code></pre> <p>splash.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#ffffaa"&gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_centerInParent="true" /&gt; &lt;/RelativeLayout&gt; </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.
    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