Wednesday, 31 July 2013

Splash screen in android.

Splash screen in android

The purpose of the splash screen.

1.Downloading data and storing in SQLite database

2.Downloading required images.
3.Fetching and parsing JSON/XML
4.sending device information/registering the device to our server

//Here you have to set splash screen layout.



splash_screen.xml


 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" a
ndroid:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ImageView android:id="@+id/imageView1"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/india1" />

<TextView android:id="@+id/txt_splash_head"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/imageView1"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="INDIA NEWS Live"
android:textSize="25sp"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>


Splashscreen.Java
 
public class Splash extends Activity { 
TextView txt_head;    // Splash screen timer   
private static int SPLASH_TIME_OUT = 3000; 
Typeface font;    
@Override   
protected void onCreate(Bundle savedInstanceState) {       
super.onCreate(savedInstanceState);       
this.requestWindowFeature(Window.FEATURE_NO_TITLE);       
setContentView(R.layout.splashscreen);     
txt_head=(TextView)findViewById(R.id.txt_splash_head); 
txt_head.setTypeface(font);       
new Handler().postDelayed(new Runnable() {                        
@Override           
public void run() {               
// This method will be executed once the timer is over                /
/ Start your app main activity                                           
Intent i = new Intent(Splash.this, Headline_main.class);               
startActivity(i);                
// close this activity               
finish();                                            
}       
},
SPLASH_TIME_OUT);   
} }

No comments: