1) Create a class splash screen.xml
========================
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:id="@+id/img_splash"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/splash_screen" />
2)create java file named SpashScreen.java
================================
package com.drc.donateandalarm;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
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);
if(Calander_Manage.session){
Calander_Manage.Set_DayLight_Saving(this);
}
thread.start();
}
// This Is run when key down
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
}
return super.onKeyDown(keyCode, event);
}
private Handler handler = new Handler();
private Thread thread = new Thread() {
public void run() {
try {
Thread.sleep(2000);
handler.post(mRunnable);
}
catch (Exception e) {
e.printStackTrace();
}
}
};
private Runnable mRunnable = new Runnable()
{
public void run()
{
Intent iv = new Intent(SplashScreen.this,HomeActivity.class);
startActivity(iv);
finish();
}
};
}
========================
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/splash_screen" />
2)create java file named SpashScreen.java
================================
package com.drc.donateandalarm;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
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);
if(Calander_Manage.session){
Calander_Manage.Set_DayLight_Saving(this);
}
thread.start();
}
// This Is run when key down
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
}
return super.onKeyDown(keyCode, event);
}
private Handler handler = new Handler();
private Thread thread = new Thread() {
public void run() {
try {
Thread.sleep(2000);
handler.post(mRunnable);
}
catch (Exception e) {
e.printStackTrace();
}
}
};
private Runnable mRunnable = new Runnable()
{
public void run()
{
Intent iv = new Intent(SplashScreen.this,HomeActivity.class);
startActivity(iv);
finish();
}
};
}
No comments:
Post a Comment