Chapter 4
An Ode to Code
IN THIS CHAPTER
Understanding how an Android activity works
Creating classes and methods
Adding comments to your code
Watching the flow in an Android activity
Hello, hello, hello, … hello!
—THE THREE STOOGES IN DIZZY DETECTIVES AND OTHER SHORT FILMS
In Chapter 3, you create a Hello World app for Android. You do this with the help of Android Studio and, in the process, Android Studio composes some Java code for you. In Chapter 3, you examine a bit of this Java code.
But in Chapter 3, you only scratch the code's surface. In this chapter, you begin to examine the code in depth. When you understand how the code works, you can forge ahead to create bigger and better Android apps.
Hello, Android!
When you create a new Android app and you select Empty Activity in the Add an Activity dialog box, Android Studio creates the Java code shown in Listing 4-1.
LISTING 4-1: A Small Android Java Program
package com.allyourcode.a04_01;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override ...
Get Java Programming for Android Developers For Dummies, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.