需要帮助杀死启动事件,所以应用程序不会退出它

时间:2012-06-06 13:35:38

标签: android splash

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

}

3 个答案:

答案 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();
}