When i install an android app ,on installation complete there are two options ,'Done' and 'Open' if i choose open to run installed app, and then press home button and click on app icon (First time click on app icon) then a splash activity is opened while the app is already running.The problem is , I don't want to call splash activity if the app is running already in background.
Activities flow: 1. splash screen extends Activity 2. Main Activity extends SherlockFragmentActivity
public class SplashScreen extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
/****** Create Thread that will sleep for 5 seconds *************/
Thread background = new Thread() {
public void run() {
try {
// Thread will sleep for 5 seconds
sleep(5*1000);
// After 5 seconds redirect to another intent
Intent i=new Intent(getBaseContext(),MainActivity.class);
startActivity(i);
//Remove activity
finish();
} catch (Exception e) {
}
}
};
// start thread
background.start();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(outState);
}
}