I am working on one app which contain SplashScreen.java
my first activity. After that its show LoginActivity.java
for login. And my LoginActivity.java
class eventually start SplashActivity.java
. I want after login first time everytime i start my app SplashScreen.java
calls SplashActivity.java
instead of LoginActivity.java
. For this i made some changes in my SplashScreen.java
class but its not working fine.
SplashScreen.java Class-
public class SplashScreen extends Activity
{
private long splashDelay = 5000; //5 seconds
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
SharedPreferences pref = getSharedPreferences("ActivityPREF", Context.MODE_PRIVATE);
if(pref.getBoolean("activity_executed", false))
{
Intent intent = new Intent(this, SplashActivity.class);
startActivity(intent);
finish();
}
else
{
Editor ed = pref.edit();
ed.putBoolean("activity_executed", true);
ed.commit();
}
TimerTask task = new TimerTask()
{
@Override
public void run() {
finish();
Intent mainIntent = new Intent().setClass(SplashScreen.this, LoginActivity.class);
startActivity(mainIntent);
}
};
Timer timer = new Timer();
timer.schedule(task, splashDelay);
}
}
Anyone else help me. Now the only problem after first run. App start from SplashActivity
instead of starting from SplashScreen
.