Tuesday, December 9, 2014

Splash Screen in Android

What is Splash Screen?

when application start then first screen,called   "Splash Screen"  also called " launching screen ." it may be logo or introduction of application and show for few seconds.

     

 int splashTime=5*1000;// 5 second


 Thread splashThread=new Thread(new Runnable() {


@Override

public void run() {

// TODO Auto-generated method stub
try {
Thread.sleep(splashTime);  // sleep for 5 seconds
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// after 5 seconds it will go to next screen
finish(); // never back to splash Screen
Intent i=new Intent(SplashScreen.this, HomeActivity.class);
startActivity(i);
}
});

                      splashThread.start();


Alternate Way:

   new android.os.Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
             finish(); // never back to splash Screen
Intent i=new Intent(SplashScreen.this, HomeActivity.class);
startActivity(i);
            }

        }, splashTime);


Splash Screen Android
Splash Screen Android
visit here more tutorials:    http://www.invokecode.com 
Thank You !!

Sunday, December 7, 2014

Application Class in Android

What is Application Class in Android

create class by extend Application, in which we put data like String, Array or other type and access in All Activities.

public class MyApplication extends Application {
public static MyApplication Instance = null;

public static MyApplication getInstance() {
return Instance;
}

public String name="";     // example save name  in this class

public String getName() {
return name;                            // create getter and setter Method of name.
}

public void setName(String name) {
this.name = name;
}


}


Save Value in Application Class

MyApplication.getInstance().setName("Hello"); // save Hello name 


Get Save Value in Application Class


MyApplication.getInstance().getName();   // get save  name

Register Application class in Manifest

inside application tag

 <application
        android:name=".MyApplication" // application class name
        .............................................................
        ..............................................................
...</application>






Click here www.invokecode.com for Android Application Development Tutorial.