Which method of the lifecycle is called when orientation changes occur?
My application executes the onResume() method or maybe reloads the whole activity becau
public class MainActivity extends AppCompatActivity {
private final static String TAG = "AppActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate(Bundle) called");
setContentView(R.layout.activity_main);
}
@Override
public void onStart() {
super.onStart();
Log.d(TAG, "onStart() called");
}
@Override
public void onPause() {
super.onPause();
Log.d(TAG, "onPause() called");
}
@Override
public void onResume() {
super.onResume();
Log.d(TAG, "onResume() called");
}
@Override
public void onStop() {
super.onStop();
Log.d(TAG, "onStop() called");
}
@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestroy() called");
}
}
1) Try to run your app on your phone and/or emulator and open the Logcat => on top of the window select Verbose.
2) Now try to change the screen orientation (ex. from portrait => landscape mode).
I hope this alternative will give you more insight into the activity lifecycle.