1.4: Learning About Available Resources
- What you should already KNOW
- What you will LEARN
- What you will DO
- App overview
- Task 1. Explore the official Android documentation
- Task 2: Use project templates
- Task 3: Learn from example code
- Task 4: Many more resources
- Related concept
- Learn more
In this practical you will:
- Explore some of the many resources available to Android developers of all levels.
- Add a home screen icon to your Word List app; tapping the icon will launch the app.
What you should already KNOW
From previous practicals, you should be able to:
- Understand the basic work flow of Android Studio.
What you will LEARN
Where to find developer resources:
- Within Android Studio.
- In the official Android developer documentation on the web.
- Elsewhere on the Internet.
What you will DO
In this practical you will:
- Explore and use Android developer resources.
- Use developer resources to figure out how to add an icon to the home screen of your device.
When this icon is clicked, your app launches.
You will use the existing HelloToast app and add a launcher icon to it.
Task 1. Explore the official Android developer documentation
You can find the official Android developer documentation at:
This documentation contains a wealth of information that is kept current by Google.
1.1. Explore the official Android documentation
- Go to http://developer.android.com/index.html.
- At the top of the page, look for the Design, Develop, and Distribute links. Follow each of the links and familiarize yourself with the navigation structure.
- Design is all about Material Design, which is a conceptual design philosophy that outlines how apps should look and work on mobile devices. Scroll to the bottom of the landing page for links to resources such as sticker sheets and color palettes.
- Develop is where you can find API information, reference documentation, tutorials, tool guides, and code samples. You can use the site navigation or search to find what you need.
- Distribute is about everything that happens after you've written your app: putting it on the Play Store, growing your user base, and earning money.
- Use search or navigate the documentation to complete the following tasks:
- Add a launcher icon to the Word List app. See the API Guide to Launcher Icons to learn more about how to design effective launcher icons.
- Learn how to monitor your app's resource usage in Android Studio.
Task 2. Use project templates
Android Studio provides templates for common and recommended app and activity designs. Using built-in templates saves time, and helps you follow design best practices.
Each template incorporates an skeleton activity and user interface. You've already used the Empty Activity template. The Basic Activity template has more features and incorporates recommended app features, such as the options menu.
2.1. Explore the Basic Activity architecture
The Basic Activity template is a versatile template provided by Android Studio to assist you in jump-starting your app development.
- In Android Studio, create a new project with the Basic Activity template.
- Build and run the app.
Identify the labelled parts on the screenshot and table below. Find their equivalents on your device or emulator screen. Architecture of the Basic Activity template
# UI Description Code reference 1 Status bar
This bar is provided and controlled by the Android system.
Not visible in the template code.
It's possible to access it from your activity. For example, you can hide the status bar, if necessary.
2 AppBarLayout > Toolbar
App bar (also called Action bar) provides visual structure, standardized visual elements, and navigation. For backwards compatibility, the AppBarLayout in the template embeds a Toolbar widget with the same functionality.
Challenge: App Bar Tutorial
Change the toolbar to change the appearance of its parent, the app bar.
3 Application name
This is derived from your package name, but can be anything you choose.
4 Options menu overflow button
Menu items for the activity, as well as global options, such as "Search" and "Settings" for the settings menu. Your app menu items go into this menu.
onOptionsItemSelected()implements what happens when a menu item is selected.
res > menu > menu_main.xml
Resource that specifies the menu items for the options menu.
CoordinatorLayout is a feature-rich layout that provides mechanisms for views to interact. Your app's user interface goes inside this view group.
Notice that there are no views specified in this layout; rather, it includes another layout with
<include layout="@layout/content_main" />
where the views are specified. This separates system views from the views unique to your app.
In the example, used to display "Hello World". Replace this with the views for your app.
All your app's views are defined in this file.
7 Floating Action button (FAB) activity_main.xml
MainActivity.java > onCreate has a stub that sets an onClick listener on the FAB.
Also inspect the corresponding Java code and XML configuration files.
Being familiar with the Java source code and XML files will help you extend and customize this template for your own needs.
See Accessing Resources for details on the XML syntax for accessing resources.
- After you understand the template code, try the following:
- Change the color of the app bar (toolbar).
- Look at the styles associated with the app bar (toolbar).
- Change the name of your app that's displayed in the app bar (toolbar).
2.2. Explore how to add an activity using templates
For the practicals so far, you've used the Empty Activity and Basic Activity templates. In later lessons, the templates use will vary, depending on the task.
These activity templates are also available from inside your project, so that you can add more activities to your app after the initial project setup. (You will learn more about this this in a later chapter.)
- Create a new project or choose an existing project.
- In your project directory, in the Android view, right-click the folder with your java files.
- Choose New > Activity > Gallery.
- Add one of those activities, for example, the Navigation Drawer Activity. Find the layout files for the Navigation Drawer Activity and display them in Design.
Task 3. Learn from example code
Android Studio, as well as the Android documentation provide many code samples that you can study, copy, and incorporate with your projects.
3.1. Android code samples
You can explore hundreds of code samples directly from Android Studio.
- In Android Studio, choose File > New > Import Sample.
- Browse the samples.
- Look at the Description and Preview tabs to learn more about each sample.
- Choose a sample and click Next.
- Accept the defaults and click Finish.
3.2. Use the SDK Manager to install offline documentation
Installing Android Studio also installs essentials of the Android SDK (Software Development Kit). However, additional libraries and documentation are available, and you can install them using the SDK Manager.
- Choose Tools > Android > SDK Manager. This opens the Default Preferences settings.
- In the left-hand navigation, find and open the settings for Android SDK.
- Click SDK Platforms in the settings window. You can install additional versions of the Android system from here.
- Click on SDK Update Sites. Android Studio checks the listed and checked sites regularly for updates.
- Click on the SDK Tools tab. Here you can install additional SDK Tools that are not installed by default, as well as an offline version of the Android developer documentation. This gives you access to documentation even when you are not connected to the internet.
- Check "Documentation for Android SDK", click Apply, and follow the prompts.
- Navigate to the Android/sdk directory and open the docs folder.
- Find index.html and open it.
Task 4. Many more resources
- The Android Developer YouTube channel is a great source of tutorials and tips.
- The Android team posts news and and tips on the Official Android Blog.
- Stack Overflow is a community of millions of programmers helping each other. If you run into a problem, chances are, someone else has already posted an answer on this forum. On Stack Overflow , you can even ask, "How do I setup and use ADB over WiFi?", or "What are the most common memory leaks in Android development?"
- And last but not least, type your questions into Google search, and the Google search engine will collect relevant results from all of these resources. For example, "What is the most popular Android OS version in India?"
4.1. Search on Stack Overflow using tags
- Go to Stack Overflow
In the search box, type [android].
The  brackets indicate that you want to search for posts that have been tagged as being about Android.
- You can combine tags and search terms to make your search more specific. Search for
- [android] and [layout]
- [android] "hello world"
- Read more about the many ways in which you can search on Stackoverflow.
- Official Android Developer Documentation - http://developer.android.com
- Material Design is a conceptual design philosophy that outlines how apps should look and work on mobile devices.
- The Google Play store is Google's digital distribution system for apps developed with the Android SDK.
- Android Studio provides templates for common and recommended app and activity designs. These templates offer working code for common use cases.
- When you create a project, you can choose a template for your first activity.
- While you are further developing your app, activities and other app components can be created from built-in templates.
- Android Studio contains many code samples that you can study, copy, and incorporate with your projects.
The related concept documentation is in Android Developer Fundamentals: Concepts.
- Official Android documentation
- Image Asset Studio
- Android Monitor page
- Official Android blog
- Android Developers blog
- Google I/O Codelabs
- Stack Overflow
- Android vocabulary
- Google Developer Training website