Understanding the activity lifecycle is critical for Android developers. Each time an activity changes its stage, the framework calls a method of the activity class. Your own activities are subclasses of the core Activity class, regardless of whether you subclass it directly or using an intermediate subclass from the support library, such as AppCompatActivity.
- [Instructor] Understanding the activity life cycle…is critical for Android developers.…Each time an activity changes its state,…the framework calls a method of the activity class.…To demonstrate this,…I'll use an application…from the exercise files named Lifecycle.…I'll start by opening the main activity class.…I'll press the shift key twice,…for search everywhere,…I'll start typing the name of the class,…and then I'll select it to open it.…As with all starting applications in Android Studio,…my activity class already has an onCreate method.…
This is an override of the superclass's version…of the method.…It's marked with the override annotation.…As with most life cycle activity methods,…you typically call the superclass's version…of the method first,…and then add your own custom code.…The onCreate method…has a call to set content view,…and I'm telling it which UY to load.…In this case, I'm using an XML layout file…called activity main dot XML.…
It has a text view control here…and two buttons at the bottom.…Notice that the text view control…
David also shows how to send and receive broadcast messages that let you exchange data and notifications among the different tiers of your application. He demonstrates how to work with menus and the action bar, add a navigation drawer to a layout, and tackle advanced navigation techniques. Later courses in the Essentials series concentrate on other specific skills you can master.
- Working with events
- Handling events with Java objects and lambda expressions
- Managing navigation
- Sending data to an activity
- Opening other apps with implicit intents
- Sending and receiving broadcast messages
- Working with menus and the action bar
- Adding a navigation drawer
- Advanced navigation techniques
- Removing activities from the back stack