I\'ve created one splash screen with android studio 0.1, but when I test it on my phone(nexus s) in debugging mode with usb the image isn\'t show.. why?
this is the
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
When to call activity context OR application context?
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.
Splash screen using handler
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();
}
}
splash.xml