在OnPause中放置什么来平衡OnResume中的内容

时间:2014-03-14 00:15:30

标签: android oncreate onpause

onResume继续循环,直到我在onPause中放入某种kill命令。在onResume中,我转到另一个活动来显示一个问候屏幕。我应该在onPause中放置什么来停止onResume循环?

    @Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
}

@Override
protected void onPostResume() {

    super.onPostResume();
}

@Override
protected void onRestart() {
    // TODO Auto-generated method stub

    super.onRestart();
}

@Override
protected void onResume() {

    super.onResume();
}

@Override
protected void onStart() {
    Intent intent = new Intent(MainActivity.this, MainWelcome.class);
    startActivity(intent);
    super.onRestart();
}

Hello.class

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.welcome_screen);
    imageView = (ImageView) findViewById(R.id.welcome);
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(getResources(), R.drawable.hello_screen, options);
    imageView.setImageBitmap(
            decodeSampledBitmapFromResource(getResources(), R.drawable.hello_screen, 700, 700));
    new CountDownTimer(3000, 100) {

        @Override
        public void onFinish() {
             finish();
        }

        @Override
        public void onTick(long arg0) {
            // TODO Auto-generated method stub

        }

    }.start();

1 个答案:

答案 0 :(得分:0)

每次启动时都会重新启动活动。

@Override
protected void onStart() {
   Intent intent = new Intent(MainActivity.this, MainWelcome.class);
   startActivity(intent);
   super.onRestart();// <----Problem there
}

我认为您打算致电super.onStart();