简体   繁体   中英

Android Lifecycle - does rotating screen doesn't destroys Activity anymore?

So I've just created a dummy app, to check the Activity Lifecycle, and I was surprised, that rotating the screen doesn't provide onDestroy() anymore, is it true, or I just messed something up? I've used the Log's, so it should appear.

public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Log.i(TAG, "onCreate: "+TAG);
}


@Override
protected void onStart() {
    super.onStart();
    Log.i(TAG, "onStart: "+TAG);
}

@Override
protected void onPostResume() {
    super.onPostResume();
    Log.i(TAG, "onPostResume: "+TAG);
}

@Override
protected void onPause() {
    super.onPause();
    Log.i(TAG, "onPause: "+TAG);
}

@Override
protected void onStop() {
    super.onStop();
    Log.i(TAG, "onStop: "+TAG);
}

@Override
protected void onResume() {
    super.onResume();
    Log.i(TAG, "onResume: "+TAG);
}

@Override
protected void onDestroy() {
    super.onDestroy();
    Log.i(TAG, "onDestroy: "+TAG);
}

@Override
protected void onRestart() {
    super.onRestart();
    Log.i(TAG, "onRestart: "+TAG);
}

}

不,我认为这是Android中的更新,但是保留它是一个好习惯,因为他们仍然拥有其他配置,例如也许他们可以更改文本或屏幕的大小,但是对于旋转,您可以放心

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM