Automatic Start Of A New Activity In Android
I am creating an android application. I have a logo screen(Activity) and then my home screen(another activity). I want that when I start my application my logo screen should come a
Solution 1:
Please use this..
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
publicclassLogoextendsActivity {
protectedboolean_active=true;
protectedint_splashTime=2000;
/** Called when the activity is first created. */@OverridepublicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.logo);
Handlerhandler=newHandler();
handler.postDelayed(newRunnable() {
publicvoidrun() {
finish();
Intenti3=newIntent(Logo.this, Home.class);
startActivity(i3);
}
}, _splashTime);
}
}
Solution 2:
You can use TimerTask.On TimerTask schedule a task after 2 minutes.And perform the task below
To use Timer Task see the link TimerTask
LogoScreen.this.startActivity(new Intent(LogoScreen.this,HomeScreen.class));
Solution 3:
you can use CountDownTimer to open activity automatically after some time
when CountDownTimer finish then in the onFinish()
method you can write
code to change activity.
Post a Comment for "Automatic Start Of A New Activity In Android"