Join Michael Lehman for an in-depth discussion in this video Elements of an Android app, part of Simple Android Development Tools.
- View Offline
Time to roll up our sleeves and begin taking a look at Android Development tools. We'll begin by doing a quick overview of Android Development, and then looking at the elements of an Android app. Android development is in general hard. But there are ways to make it easier, much easier. There are Code-first tools, which means tools in which you write code in various languages. There are point-and-click code tools, in which you do very little typing, but you rearrange boxes on the screen and connect up piece of the logic of your app together using your mouse.
And then there are tools for building apps that don't require writing any code at all. There are apps, for example, to help a musician promote a band. Or a small business owner provide information to their customers that you can build that link directly to your website or to your product catalogue that don't require you to write any code at all, and we'll take a look at those at the end of the course. So let's take a look at the elements of an Android app. Then we'll take a look at the hard way: Building HelloWord in Android Studio. Then we'll look at building apps with custom logic, and then we'll look at building apps with pre-canned logic.
Every Android app has one or more screens. And in the world of Android, screens are called Activities. Each screen, or each activity, contains a set of controls and each controls, triggers some kinds of logic or actions. Such as when you push a button and a sound happens, or a piece of text changes on the screen, or something changes color. Actions can also read from Sensors, Controls, and Storage. When you create an action that responds say, to a button, you can take a picture with the camera, you can check and see the current status of WiFi, you could look to see whether a check box is checked.
Or you can read or write something from data storage on your device. Actions can write to effectors, things like the haptic motor inside your device to make it buzz in your hand, the headphones or speakers to make it do some kind of a sound. They can also write to other controls, so that you can tap on one button which may enable a check box. Or make a control which was previously hidden, visible. And of course, actions can also write to storage, you can save data that the users typed into a text box, you can record someone's voice and save it to a file, you can take a movie, all those sorts of things.
Each screen is a separate activity. That means that if you want to have more than one screen, you have to have more than one activity. Each activity can be invoked by some logic. For example, you could have a main screen that contains your basic logic for your application. And you can have an about screen, and a setting screen. In order to show the about screen, the user typically does something on your main screen. Taps a button for example, which invokes or shows the other activity which might show the about information about your app.
Every activity contains layouts and the layouts contain controls. And what I mean by a layout is something that says the controls in this particular layout are ordered from top to bottom on the screen, one on top of each other. Or they might be ordered left to right on the screen, one to the right of the next. And you can mix and match those in order to create various types of grids and tables, and arrangement of controls. An activity also contains the logic for handling control interactions for your particular activity. That means, if you have something that has a button on the screen in a particular activity.
You have to have the logic for handling what happens when the user taps on that button, in the enclosing activity. Controls accept user input and display output. Controls such as buttons, checkboxes, sliders accept user input when the user taps on the screen and moves from one side to the other. Or, for example, taps on a checkbox, which makes the check mark show or disappear. Controls control visual layout. That means you can have one control manipulate the status of another control.
So that you can, for example, change which picture it's showing, or make a particular control appear or disappear on the screen. Input controls have actions. So the action is where you put your logic. When the user taps on a control, a particular action is invoked that says what to do when the user taps on that control. And every control has a variety of properties. Not all controls have the same properties, but most controls have properties such as text, width, height, alignment, whether they're visible or not.
If they're a certain kind of a control, they might be able to have a background color or background image. So it's important as you being to learn about controls to learn about the properties of that control because you'll want to be able to set them. Either at design time when you're building your app, or at run time when you're actually running your app. So for example, if the user taps on one button, you might make the color of another button or the content of an image control change its currently displayed value. So, that's a look at the basic elements of an Android app.
Next up, we'll look at controls both input and output in more detail.
- Understanding the elements of an Android app, such as controls, sensors, effectors, and storage
- Exploring MIT App Inventor 2
- Getting started with Basic4android
- Building simple apps
- Testing apps on Android emulators and devices
- Sharing apps
- Creating hybrid apps with Appy Pie, Make Me Droid, and AppMakr