The Android Development Lifecycle
After completing this video, you will be able to describe the various steps involved in building an Android app, from creating build scripts to testing on a virtual device emulator.
We have so far been introduced to a lot of new terms and new concepts during this course. And while those will make things easier for us when it comes to building an Android App, I'm now going to try to structure all of those pieces together to see exactly what steps one needs to go through when building such an app. And in the process, we'll also fill in some of the missing bits of information.
Now, before we get started, I'd like to point out that there is no single approach towards Android App development. And in the end, you'll have to decide what process is the best for you. But given that this is an introductory course on Android programming, I'm going to suggest a template which you can at least start with and potentially refine and build upon later. So what are the different steps for Android development? Now these are not precisely in order. However, you will need to take care of the build scripts and the manifest file for your app.
This will include setting up different repositories and dependency for your android apps. And in the manifest file, you can decide on which activity within your app will serve as the launcher. This is typically a splash screen. But of course this is something you can configure according to your own needs. Furthermore, if your app makes use of the Internet in order to retrieve data, this is something to configure within the app's manifest. Another step is to define the different views which make up your app.
For instance, these can involve creating the layout for the different activities. One of the activities can include a splash screen, which can serve as the launcher activity. And if your app needs a navigation pane, you can define a layout for this as well. Once the view for the activities have been defined, you should go ahead and code their behavior. So all the controller code is usually written in Kotlin or Java. And if your app needs to retrieve and parse data from the Internet, this is something you can define within the controller.
Furthermore, any user of your app will typically switch from one activity to another. And this handover is also something which can be coded at this stage. And finally, once all the code is ready for your app, it's time for the test and package phase. Leaving aside automated test for now. One way to test your app is to first launch it on an Android virtual device, or AVD emulator. Once this is done you can bring up your app and then verify that it behaves exactly as you intended it to. Once everything checks out, you can also package your app into an APK file.
This is a file you will need to create if you'd like to install your app on a physical device. All right, so now that we have some idea of the different steps involved, let's get a little more specific and focus on the handover between different activities. Well, for this we discuss the concept of intents in Android. Now this is an object which is commonly used in order to start one activity from another. And while doing so, it is also able to convey a message from the originating activity.
So for example, if you have one activity which takes in some user input, generates an output based on that, and that output is displayed in a different activity. Well, this is where intents come into the picture, where the output can be passed from the originating activity to the new activity. Now there are different kinds of intents. Explicit intents are those which bring up a specific component or a specific activity for example, alternatively, there are implicit intents, which allow the operating system or even the user to pick an eligible component.
One thing to note that the component which is specified, need not be an activity within the same app. So for example, if a user has opted to open a particular file in one application, this may open up any application which is capable of displaying it. So if you have an activity representing the login view of your application, if a user has successfully been authenticated, they may be directed to a specific homepage activity. And this is something which can be accomplished using an explicit intent.
Moving along then to a specific type of activity which is common in Android applications and this is a navigation pane. This is where a drawer or a menu pops up when you click a particular button, or perform a swipe on your app. And this menu allows you to navigate to different parts of your app. One of the view elements which can be used to implement this is called the Navigation view. This in turn can include a header as well as a menu comprising a number of items. The navigation view itself can be embedded within a structure called a drawer layout.
I don't expect you to remember these terms and we will be implementing these during the labs of this learning path. But this is just to get you comfortable with the terminology. Now, each activity in your app will by default have an ActionBar at the top. Now it is possible for a DrawerLayout to be accessed from this ActionBar. But to enable that, another object called an ActionBarDrawerToggle will need to be created. This will add the three horizontal lines or the hamburger icon to the action bar and tapping that will pull up the navigation pane.
Now once all of the coding is complete, it means that you are ready to launch your app on a virtual device emulator. Well, to make this happen, you will first need to install a virtual device. And if you happen to be using an IDE, such as Android Studio, then there are a variety of such devices available. Some of these are available by default on Android Studio, while others can be separately installed. Once you had the virtual device, well, you will also need to pick an Android OS version to be installed on it.
In the end, it is possible that you have different combinations of devices and Android OS versions to ensure that your app works across a variety of such platforms. Once you do have everything installed though, you can pick which specific device you would like your app to run on and then verify it's behavior on that particular device and OS combination. Let us take a closer look at the AVD Emulator. As I had mentioned, this translates to a specific combination of the device and the Android OS version.
In any case, the virtual device will come installed with the standard Android applications. So for example, you have Google Play, Maps, and you can also access the Virtual Device Settings. Now this device emulator does have the ability to simulate taps, scrolls, swipes, and other behaviors which a user can perform on a physical device. Furthermore, within the emulator, you can also bring up a virtual keyboard for editable fields in your app. The AVD emulator is crucial during the development of your app.
Since it does enable quick feedback for your code, so for example, you can test your app in both portrait and landscape modes and make some quick changes if there are any glitches in your app. Furthermore, this emulator also allows you to take pictures with a virtual camera. This is useful for applications which do involve the use of a camera. Now, it is possible that your app is meant to work in conjunction with some other apps. And with the AVD emulator, it is possible to install multiple applications on the same device.
And of course, the final purpose of all of this virtual devices is to ensure that your app is compatible with multiple devices and Android OS versions.
More videos
Learn more on Codecademy
- Course
Learn the Basics of Android
Get started developing Android Apps! Get to know the Android programming environment and skills needed to build basic Android appsWith CertificateIntermediate1 hour - Free course
Learn Kotlin
Learn Kotlin, the expressive, open-source programming language developed by JetBrains.Beginner Friendly9 hours