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();

2 番目のソリューション

AndroidManifest ファイル内

<activity android:noHistory="true"
            android:name=".splash" />
于 2012-06-06T13:36:55.347 に答える
0

finsh(); を追加します。としてコードで:

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 に答える