0

我创建了一个启动事件并将其设置为休眠 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();
}

}

4

3 回答 3

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" />
于 2012-06-06T13:36:55.347 回答
0

添加完成();在代码中:

Intent openApp = new Intent("com.iqmobile.chris.IQMOBILEACTIVITY");
                startActivity(openApp);
               splash.this.finsh();
于 2012-06-06T13:36:49.250 回答
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();
}
于 2012-06-06T13:42:04.687 回答