Java Android Programming Example Using Classes - dummies

Java Android Programming Example Using Classes

By Barry Burd

Classes and subclasses are shown in a practical Java Android programming example here. How does an Android app use classes and subclasses? This example is ruefully simple, but it’s one that an Android programmer sees every day. It’s an Android Activity.

A typical Android app displays one screen at a time, as shown in the figure. A screenful of material might present the user with a list of options and a Start button. The next screenful (after the user clicks Start, for example) shows some helpful information, such as a map, a video, or a list of items for sale.

When the user touches on this information screen, the app’s display changes to reveal a third screen, showing detailed information about whatever option the user selected. Eventually, the user dismisses the detail screen by clicking the Back button.

Android displays a sequence of screens.
Android displays a sequence of screens.

In Android terminology, each screenful of material is an activity. As the user progresses through the sequence of screens displayed in the figure, Android displays three activities. (It displays the middle activity twice — once after the user clicks Start and a second time after the user dismisses the detailed-info activity.)

Android developers deal with activities all the time, so the creators of Android have created an Activity class. The Activity class is part of Android’s Application Programming Interface (API), the enormous library of classes that’s available to every Android developer.