Getting Started in Android Development
Part 1 -
Welcome to the first of a series of tutorials focused on getting started in Android Development. In this series I will take you through the basic elements needed to get you started and self-
The Android Activity
An Android activity is a core function of any Android application. An activity is a piece of code that performs specific tasks associated with the app. An activity often has a layout associated with it and so can be related to specific screens of an app.
The diagram below shows a simple shopping lists app with three screens. You can see how you can produce a high level design for an app in this way. Each of the three boxes represents an Activity that perform a set function. There is a main activity that is loaded on start-
The diagram below shows how the actual app may look. Here you can see that each of the Activities has a layout associated with it.
The Activity Lifecycle
It’s worth spending a little time looking at the Activity Lifecycle as we will come across these Activity states and methods right from your first project. Having an Activity lifecycle makes real sense. Activities must be created when they are first called and destroyed when they are finished with. But you may be playing a game that is an Activity and then a voice call comes into your phone. You will want to pause the current activity to take that call and then resume it when you end the call. Java methods are called when the Activity enters a state change. The onCreate(), onPause() and onResume() methods are the three most common methods associated with the Activity lifecycle that you will see.