我正在开发一个包含SplashScreen.java
我的第一个活动的应用程序。之后显示LoginActivity.java
登录。而我的LoginActivity.java
课终于开始了SplashActivity.java
。每次我启动我的应用程序SplashScreen.java
调用SplashActivity.java
而不是LoginActivity.java
. 为此,我在我的SplashScreen.java
课堂上进行了一些更改,但效果不佳。
SplashScreen.java 类-
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);
}
}
其他人帮助我。现在第一次运行后唯一的问题。应用程序从开始SplashActivity
而不是从SplashScreen
.