Reputation: 329
The main goal is to give you practice determining what methods are called during the lifecycle of your app. You must do each task and record which methods were called and in what order. The following methods should be overwritten so you can determine which ones are being called and when:
• onCreate
• onStart
• onResume
• onPause
• onStop
• onRestart
• onDestroy
• onSaveInstanceState
• onRestoreInstanceState
• onConfigurationChanged
package com.example.martij62.myapplication;
import android.content.res.Configuration;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState ) {
super.onCreate(savedInstanceState);
if(getResources().getConfiguration().orientation==
Configuration.ORIENTATION_LANDSCAPE) {
setContentView(R.layout.activity_landscape) ;
} else {
setContentView(R.layout.activity_main) ;
}
getWindow().setSoftInputMode (
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) ;
}
}
How am I suppose to implement all of these methods into my code? Whenever I try I get errors. I'm unsure how to run all of these at once or individually. He wants us to implement and find out what each one does.
Upvotes: 1
Views: 62
Reputation: 142
Use a method under create method.
`@Override
protected onstart()
{
super.onPause();
Log.i(app."on Pause")
}`
Do that for each method and watch the log as its called.
Upvotes: 1