Exploring the Android SDK Android

The Android SDK comes with five major components: the Android SDK License Agreement, the Android Documentation, Application Framework, Tools, and Sample Applications.

Understanding the Android SDK License Agreement

Before you can download the Android SDK, you must review and agree to the Android SDK License Agreement. This agreement is a contract between you (the developer) and Google (copyright holder of the Android SDK).

Even if someone at your company has agreed to the Licensing Agreement on your behalf, it is important for you, the developer, to be aware of a few important points:

  1. Rights granted: Google (as the copyright holder of Android) grants you a limited, worldwide, royalty-free, non-assignable, and non-exclusive license to use the SDK solely to develop applications for the Android platform. Google (and third-party contributors) are granting you license, but they still hold all copyrights and intellectual property rights to the material. Using the Android SDK does not grant you permission to use any Google brands, logos, or trade names. You will not remove any of the copyright notices therein. Third-party applications that your applications interact with (other Android apps) are subject to separate terms and fall outside this agreement.
  2. SDK usage: You may only develop Android applications. You may not make derivative works from the SDK or distribute the SDK on any device or distribute part of the SDK with other software.
  3. SDK changes and backward compatibility: Google may change the Android SDK at any time, without notice, without regard to backward compatibility. Although Android API changes were a major issue with prerelease versions of the SDK, recent releases have been reasonably stable. That said, each SDK update does tend to affect a small number of existing applications in the field, necessitating updates.
  4. Android application developer rights: You retain all rights to any Android software you develop with the SDK, including intellectual property rights.You also retain all responsibility for your own work.
  5. Android application privacy requirements: You agree that your applications will protect the privacy and legal rights of its users. If your application uses or accesses personal and private information about the user (usernames, passwords, and so on), then your application will provide an adequate privacy notice and keep that data stored securely. Note that privacy laws and regulations may vary by user location; you as a developer are solely responsible for managing this data appropriately.
  6. Android application malware requirements: You are responsible for all applications you develop. You agree not to write disruptive applications or malware. You are solely responsible for all data transmitted through your application.
  7. Additional terms for specific Google APIs: Use of the Android Maps API is subject to further Terms of Service (specifically use of the following packages: com. google. android. maps and com.android.location.Geocoder).You must agree to these additional terms before using those specific APIs and always include the Google Maps copyright notice provided. Use of Google Data APIs (Google Apps such as Gmail, Blogger, Google Calendar, Google Finance Portfolio Data, Picasa, YouTube, and so on) is limited to access that the user has explicitly granted permission to your application by accepted permissions provided by the developer during installation time.
  8. Develop at your own risk: Any harm that comes about from developing with the Android SDK is your own fault and not Google’s.

Reading the Android SDK Documentation

A local copy of the Android documentation is provided in the /docs subfolder on disk.

The documentation is now divided into seven main sections:

  • The Home tab is your general starting point within the Android documentation. Here you find developer announcements and important links to the latest hot topics in Android development.
  • The SDK tab provides information about the different Android SDK versions available, as well as information about the Android Native Development Kit (NDK).You find the Android SDK release notes here as well.
  • The Android SDK documentation.

    The Android SDK documentation

  • The Dev Guide tab introduces the Android platform and covers best practices for Android application design and development, as well as information about publishing applications.
  • The Reference tab provides a drill-down listing of the Android APIs with detailed coverage of specific classes and interfaces.
  • The Resources tab provides access to Android technical articles and tutorials. Here you also find links to the Android community online (groups, mailing list, and official Twitter feed), as well as the sample applications provided along with the Android SDK.
  • The Videos tab provides access to online videos pertaining to Android development, including videos about the platform, developer tips, Android development sessions from the annual Google I/O conference, and developer sandbox interviews.
  • The Blog tab provides access to the online blog published by the Android development team. Here you find announcements about SDK releases, helpful development tips, and notices of upcoming Android events.

The Android documentation is provided in HTML format locally and online . Certain networked features of the Android documentation (such as the Blog and Video tabs) are only available online.

Exploring the Android Application Framework

The Android application framework is provided in the android.jar file. The Android SDK is made up of several important packages, as shown in Table.

Important Packages in the Android SDK

Important Packages in the Android SDK

There is also an optional Google APIs Add-On, which is an extension to the Android SDK that helps facilitate development using Google Maps and other Google APIs and services. For example, if you want to include the MapView control in your application, you need to install and use this feature. This Add-On corresponds to the com. google.* package (including com.google.android.maps) and requires agreement to additional Terms of Service and registration for an API Key. For more information on the Google APIs Add-On.

Getting to Know the Android Tools

The Android SDK provides many tools to design, develop, debug, and deploy your Android applications. The Eclipse Plug-In incorporates many of these tools seamlessly into your development environment and provides various wizards for creating and debugging Android projects.

Settings for the ADT plug-in are found in Eclipse under Window, Preferences, Android. Here you can set the disk location where you installed the Android SDK and tools, as well as numerous other build and debugging settings.

The ADT plug-in adds a number of useful functions to the default Eclipse IDE. Several new buttons are available on the toolbar, including buttons to

  • Launch the Android SDK and AVD Manager
  • Create a new project using the Android Project Wizard
  • Create a new test project using the Android Project Wizard
  • Create a new Android XML resource file

These features are accessible through the Eclipse toolbar buttons shown in Figure.

Android features added to the Eclipse toolbar.

Android features added to the Eclipse toolbar.

There is also a special Eclipse perspective for debugging Android applications called DDMS (Dalvik Debug Monitor Server).You can switch to this perspective within Eclipse by choosing Window, Open Perspective, DDMS or by changing to the DDMS perspective in the top-right corner of the screen. We talk more about DDMS later in this chapter. After you have designed an Android application, you can also use the ADT plug-in for Eclipse to launch a wizard to package and sign your Android application for publication. We talk more about this in Chapter “Selling Your Android Application.”

Android SDK and AVD Manager

The Android SDK and AVD Manager, shown in Figure, is a tool integrated into Eclipse. This tool performs two major functions: management of multiple versions of the Android SDK on the development machine and management of the developer’s Android Virtual Device (AVD) configurations.

The Android SDK and AVD Manager.

The Android SDK and AVD Manager.

Much like desktop computers, different Android devices run different versions of the Android operating system. Developers need to be able to target different Android SDK versions with their applications. Some applications target a specific Android SDK, whereas others try to provide simultaneous support for as many versions as possible.

The Android SDK and AVD Manager facilitate Android development across multiple platform versions simultaneously. When a new Android SDK is released, you can use this tool to download and update your tools while still maintaining backward compatibility and use older versions of the Android SDK.

The tool also manages the AVD configurations. To manage applications in the Android emulator, you must configure an AVD. This AVD profile describes what type of device you want the emulator to simulate, including which Android platform to support. You can specify different screen sizes and orientations, and you can specify whether the emulator has an SD card and, if so, what capacity.

Android Emulator

The Android emulator, shown in Figure, is one of the most important tools provided with the Android SDK. You will use this tool frequently when designing and developing Android applications. The emulator runs on your computer and behaves much as a mobile device would. You can load Android applications into the emulator, test, and debug them.

The Android emulator.

The Android emulator

The emulator is a generic device and is not tied to any one specific phone configuration. You describe the hardware and software configuration details that the emulator is to simulate by providing an AVD configuration.

Dalvik Debug Monitor Server (DDMS)

The Dalvik Debug Monitor Server (DDMS) is a command-line tool that has also been integrated into Eclipse as a perspective. This tool provides you with direct access to the device—whether it’s the emulator virtual device or the physical device. You use DDMS to view and manage processes and threads running on the device, view heap data, attach to processes to debug, and a variety of other tasks.

Using DDMS integrated into an Eclipse perspective.

Using DDMS integrated into an Eclipse perspective

Android Debug Bridge (ADB)

The Android Debug Bridge (ADB) is a client-server tool used to enable developers to debug Android code on the emulator and the device using a standard Java IDE such as Eclipse. The DDMS and the Android Development Plug-In for Eclipse both use the ADB to facilitate interaction between the development environment and the device (or emulator). Developers can also use ADB to interact with the device file system, install Android applications manually, and issue shell commands. For example, the sqlite3 shell commands enable you to access device database.The Application Exerciser Monkey commands generate random input and system events to stress test your application. One of the most important aspects of the ADB for the developer is its logging system (Logcat).

Android Hierarchy Viewer

The Android Hierarchy Viewer, a visual tool that illustrates layout component relationships, helps developers design and debug user interfaces. Developers can use this tool to inspect the View properties and develop pixel-perfect layouts. For more information about user interface design and the Hierarchy Viewer, see Chapter “Designing User Interfaces with Layouts.”

Screenshot of the Android Hierarchy Viewer in action.

Screenshot of the Android Hierarchy Viewer in action

Other Tools

Android SDK provides a number of other tools provided with the Android SDK. Many of these tools provide the underlying functionality that has been integrated into Eclipse using the Android Development Tools (ADT) plug-in. However, if you are not using Eclipse, these tools may be used on the command-line.

Other tools are special-purpose utilities. For example, the Draw Nine-patch tool enables you to design stretchable PNG images, which is useful for supporting different screen sizes. Likewise, the layout opt tool helps developers optimize their user interfaces for performance. We discuss a number of these special tools in later chapters as they become relevant.

Exploring the Android Sample Applications

The Android SDK provides many samples and demo applications to help you learn the ropes of Android Development. Many of these demo applications are provided as part of the Android SDK and are located in the /samples subdirectory of the Android SDK. You can find more sample applications on the Android Developer website under the Resources tab.

Some of the most straightforward demo applications to take a look at are:

  • ApiDemos: A menu-driven utility that demonstrates a wide variety of Android APIs, from user interface widgets to application lifecycle components such as services, alarms, and notifications.
  • Snake: A simple game that demonstrates bitmap drawing and key events.
  • NotePad: A simple list application that demonstrates database access and Live Folder functionality.
  • LunarLander: A simple game that demonstrates drawing and animation.

There are numerous other sample applications, but they demonstrate very specific Android features that are discussed later in this book.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Android Topics