SplashScreen
========
public class SplashScreen extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.xsplashscreen);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
// DisplayMetrics metrics = new DisplayMetrics();
// getWindowManager().getDefaultDisplay().getMetrics(metrics);
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
Thread th = new Thread(){
public void run(){
try{
sleep(2500);
}catch(Exception e){
e.printStackTrace();
}finally{
Intent in = new Intent(getBaseContext(), MainActivity.class);
startActivity(in);
finish();
}
};
};
th.start();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME){
return true;
}
return super.onKeyDown(keyCode, event);
}
}
========
public class SplashScreen extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.xsplashscreen);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
// DisplayMetrics metrics = new DisplayMetrics();
// getWindowManager().getDefaultDisplay().getMetrics(metrics);
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
Thread th = new Thread(){
public void run(){
try{
sleep(2500);
}catch(Exception e){
e.printStackTrace();
}finally{
Intent in = new Intent(getBaseContext(), MainActivity.class);
startActivity(in);
finish();
}
};
};
th.start();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME){
return true;
}
return super.onKeyDown(keyCode, event);
}
}
No comments:
Post a Comment