我创建了一个启动事件,并将其设置为3秒睡眠状态。一切正常,但当你退出应用程序时,它会带你回到飞溅。有没有办法用我拥有的代码来杀死它,或者我需要以不同的方式编写它。
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();
}
}
答案 0 :(得分:2)
splash.this.finish();
后 startActivity(openApp);
Intent openApp = new Intent("com.iqmobile.chris.IQMOBILEACTIVITY");
startActivity(openApp);
splash.this.finish();
第二个解决方案
AndroidManifest文件中的
<activity android:noHistory="true"
android:name=".splash" />
答案 1 :(得分:0)
和完成();在代码中:
Intent openApp = new Intent("com.iqmobile.chris.IQMOBILEACTIVITY");
startActivity(openApp);
splash.this.finsh();
答案 2 :(得分:0)
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();
}