title: How to add splash screen
body: <p>i'm a newwbie in java, and i want to add splash screen to a code. so i have created a layout XML named 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="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/splash" &gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and i have created a java classe named splash.java :</p>
  
  <pre><code>package com.test.test;
  
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Handler;
  import android.os.Bundle;
  import android.view.Window;
  
  import com.test.test.R;
  
  
  public class Splash extends Activity {
  
  private boolean backbtnPress;
  private static final int SPLASH_DURATION = 3000;
  private Handler myHandler;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
  
      getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
      getActionBar().hide();
  
      setContentView(R.layout.splash);
  
      myHandler = new Handler();
      myHandler.postDelayed(new Runnable() {
  
          @Override
          public void run() {
              finish();
  
              if(!backbtnPress)
              {
                  Intent intent = new Intent(Splash.this,MainActivity.class);
                  Splash.this.startActivity(intent);
              }
  
          }
      }, SPLASH_DURATION);
  
  }
  
  @Override
  public void onBackPressed() {
      // TODO Auto-generated method stub
  
      backbtnPress = true;
      super.onBackPressed();
  }
  }
  </code></pre>
  
  <p>but it does not work, when i run the app i find two app icons on device.</p>
  
  <p>can you help me please</p>
  
  <p>Thank you in advance!</p>