我想为SplashScreen屏幕增加时间,但我做错了什么? 我该如何纠正? 你能帮助我吗 ? 因为,我必须使用两步登录屏幕。
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
public class MainSlider extends Activity{
/** Duration of wait **/
private final int SPLASH_DISPLAY_LENGTH = 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
SharedPreferences settings=getSharedPreferences("prefs",0);
boolean firstRun=settings.getBoolean("firstRun",false);
if(firstRun==false)//if running for first time
//Splash will load for first time
{
SharedPreferences.Editor editor=settings.edit();
editor.putBoolean("firstRun",true);
editor.commit();
Intent i=new Intent(MainSlider.this,MaterialIntro.class);
startActivity(i);
finish();
}, SPLASH_DISPLAY_LENGTH);
else
{
Intent a=new Intent(MainSlider.this,MainActivity.class);
startActivity(a);
finish();
}
}
}