Android 需要帮助来终止飞溅事件,以便应用程序不会退出到它吗
我已经创建了一个splash事件,并将其设置为睡眠3秒。一切正常,但当您退出应用程序时,它会将您带回splash。有没有一种方法可以用我现有的代码来解决这个问题,或者我需要用另一种方式来编写它Android 需要帮助来终止飞溅事件,以便应用程序不会退出到它吗,android,splash-screen,Android,Splash Screen,我已经创建了一个splash事件,并将其设置为睡眠3秒。一切正常,但当您退出应用程序时,它会将您带回splash。有没有一种方法可以用我现有的代码来解决这个问题,或者我需要用另一种方式来编写它 public class splash extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.o
public class splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread timer = new Thread(){
public void run(){
try{
sleep(3000);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent openApp = new Intent("com.iqmobile.chris.IQMOBILEACTIVITY");
startActivity(openApp);
}
}
};
timer.start();
}
}添加finsh();代码为:
Intent openApp = new Intent("com.iqmobile.chris.IQMOBILEACTIVITY");
startActivity(openApp);
splash.this.finsh();
splash.this.finish()代码>启动startActivity(openApp)后代码>
第二种解决方案
在AndroidManifest文件中
<activity android:noHistory="true"
android:name=".splash" />
Wow..太简单了,我错过了。谢谢萨米尔!
<activity android:noHistory="true"
android:name=".splash" />
mSplashThread = new Thread() {
@Override
public void run() {
try {
synchronized (this) {
wait(3000);
}
} catch (InterruptedException ex) {
}
finish();
Intent intent = new Intent();
intent.setClass(FirstActivity.this,
SecondActivity.class);
startActivity(intent);
}
};
mSplashThread.start();
}