public class MainActivity extends AppCompatActivity {
private String TAG = "JJWorld";
private TextView textView;
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(TAG, "onCreate....");
initView();
textView.setText("开始时间:" + DateUtils.getNowTime());
}
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
switch (newConfig.orientation) {
case Configuration.ORIENTATION_PORTRAIT:
textView.setText("竖屏:" + DateUtils.getNowTime());
break;
case Configuration.ORIENTATION_LANDSCAPE:
textView.setText("横屏:" + DateUtils.getNowTime());
break;
default:
break;
}
}
@Override
protected void onStart() {
super.onStart();
Log.i(TAG, "onStart....");
}
@Override
protected void onResume() {
super.onResume();
Log.i(TAG, "onResume....");
}
@Override
protected void onPause() {
super.onPause();
Log.i(TAG, "onPause....");
}
@Override
protected void onStop() {
super.onStop();
Log.i(TAG, "onStop....");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.i(TAG, "onDestroy....");
}
private void initView() {
textView = (TextView) findViewById(R.id.textView);
}
}
AndroidManifest.xml



