This article is a guide for members who have no experience in Android development in the company to create an application that understands the life cycle of Activity, which is the basis of Android, by movement before self-study. Therefore, please note that most of the detailed explanations are omitted. The development machine is assumed to be a Windows 10 machine.
Please prepare the development environment. The following three points need to be prepared. --Android Studio (version at the time of writing is 3.4.1)
[Here](https://developer.android.com/studio/?gclid=Cj0KCQjwitPnBRCQARIsAA5n84lkUis7r2qTcFHo4UK1m7AyGlIYs7bbP2By1_zZ9hYPioz39oOtmxMaAsSAEALw_wc The latest version is fine.
You can open "SDK Manager" from the button on the upper right of Android Studio.
You can open "Android Virtual Device Manager" from the button on the upper right of Android Studio. Please create the OS with Oreo or above.
If you are familiar with Eclipse, you may want to select Eclipse from Settings → Keymap.
Select Empty Activity
Language: Java Minimum API level:API 27 Use androidx. * artifacts: Check
Check the life cycle of Activity and Fragment while actually moving it. Implement to output the log in the callback of each life cycle.
[About the life cycle of Activity](https://developer.android.com/guide/components/activities.html? hl=ja#ImplementingLifecycleCallbacks)
MainActivity.java
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");
}
@Override
protected void onRestart() {
super.onRestart();
Log.i(TAG, "onRestart");
}
@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");
}
}
When you press the execute button, a list of execution destination devices will appear, so select the device and press OK.
When the app starts, let's check the timing when the callback is called in the Logcat console of Android Studio. At this time, it will be easier to see if the log level to be displayed is set to Info or higher.
NEXT STEP Next, we will create the UI. First Android UI creation for busy people (In addition, Data Binding experience)
Recommended Posts