Using the Android Developer Documentation

Android Lint errors will tell you what API level your incompatible code is from. But you can also find out which API level particular classes and methods belong to in Android’s developer documentation.

It is a good idea to get comfortable using the developer documentation right away. There is far too much in the Android SDKs to keep in your head, and, with new versions appearing regularly, you will need to learn what is new and how to use it.

The Android developer documentation is an excellent and voluminous source of information. The main page of the documentation is developer.android.com. It is split into three parts: Design, Develop, and Distribute. It is all worth perusing when you get a chance. The Design section of the documentation includes patterns and principles for the UI design of your apps. The Develop section contains documentation and training. The Distribute section shows you how to prepare and publish your apps on Google Play or through open distribution.

The Develop section is further divided into six areas:

Training

Beginning and advanced developer training modules, including downloadable sample code

API Guides

Topic-based descriptions of app components, features, and best practices

Reference

Searchable, linked documentation of every class, method, interface, attribute constant, etc. in the SDK

Samples

Sample code demonstrating some examples of how to use the APIs

Android Studio

Information about the Android Studio IDE

Android NDK

Descriptions and links about the Native Development Kit, which allows you to write code in C and C++

Google Services

Information about Google’s proprietary APIs, including Google Maps and Google Cloud Messaging

You do not have to be online to have access to the documentation. In the SDK Manager, download the documentation for a particular Android version, then navigate on your filesystem to where you have downloaded the SDKs. There is a docs directory that contains the complete documentation.

To determine what API level ViewAnimationUtils belongs to, search for this class using the search bar at the top right of the browser. You will see results from a few different categories. Make sure that you select a result that is from the reference section (there is a filter on the left).

Select the first result and you will be sent to the ViewAnimationUtils class reference page shown in Figure 6.2. At the top of this page are links to its different sections.

Figure 6.2  ViewAnimationUtils reference page

Screenshot shows ViewAnimationUtils reference page in the web browser.

Scroll down, find the createCircularReveal(…) method, and click on the method name to see a description. To the right of the method signature, you can see that createCircularReveal(…) was introduced in API level 21.

If you want to see which ViewAnimationUtils methods are available in, say, API level 19, you can filter the reference by API level. On the lefthand side of the page where the classes are indexed by package, find where it says API level: 21. Click the adjacent control and select 19 from the list. In most cases, everything that Android has introduced after API level 19 will be grayed out. In this case, ViewAnimationUtils was introduced in API level 21, so you will see a warning indicating that this entire class is not available at all on API level 19.

The API level filter is much more useful for a class that is available at the API level that you are using. Search for the reference page on the Activity class in the documentation. Change the API level filter back down to API level 19 and notice that many methods have been added since that API, such as onEnterAnimationComplete, which is an addition to the SDK in Lollipop that allows you to provide interesting transitions between activities.

As you continue through this book, visit the developer documentation often. You will certainly need the documentation to tackle the challenge exercises, but also consider exploring it whenever you get curious about particular classes, methods, or other topics. Android is constantly updating and improving the documentation, so there is always something new to learn.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.160.216