1. Presenting Android

The mobile development community has helped transform the Android operating system (OS) into the global leader. Mobile device users have shown their passion for Android. Developing for Android is now a primary focus for companies that would like to target and retain a mobile user base for their businesses. Handset manufacturers and mobile operators have invested heavily in Android to create unique experiences for their customers. Entrepreneurs and startups are delivering Android-application user experiences that you cannot find on other mobile platforms or other platforms such as desktops. Further, new device categories continue to emerge, and the creators of those devices are showing favor for powering these devices with Android.

Android has dominated the market as a game-changing platform for the mobile development community. An innovative and open platform, Android is addressing the increasing demands of the marketplace as it continues to expand to new types of devices beyond phones and tablets, and further penetrates the far regions of the globe. This chapter introduces the Android OS and where the platform fits into the marketplace, and discusses how the platform operates.

The Android Open Source Project (AOSP)

The Android Open Source Project (AOSP) is an initiative led by Google that makes the source code of the Android OS available for all to read, review, and modify to your liking. You may make contributions of your own custom code for everyone else to use if you so desire. The main goal of the AOSP is to provide a set of compatibility guidelines—for OEMs and device manufacturers—for porting Android to custom devices and for building accessories that comply with Android’s open accessory standard, allowing those OEMs and manufacturers to deliver a standard experience.

Although anyone is free to fork the Android OS source code, maintaining a consistent OS experience is important for the Android ecosystem because making radical changes to that experience introduces fragmentation in the marketplace and competing Android distributions. To learn more about the AOSP and to review the OS source code, see https://source.android.com/index.html.

The Open Handset Alliance

Google has been busy spreading its vision, its brand, its search and ad-revenue-based platform, and its suite of tools to the mobile marketplace. The company’s business model has been amazingly successful on the Internet and, technically speaking, mobile isn’t that different.

Google Goes Mobile First

The company’s initial forays into mobile were beset with many problems. The freedoms Internet users enjoyed were not shared by mobile phone subscribers of older platforms because the mobile operating systems of those times were closed ecosystems—not open source like Android—so developing applications for those closed-ecosystem mobile operating systems was limited to a few players.

Internet users can choose from a wide variety of computer brands, operating systems, Internet service providers, and Web browser applications. Nearly all Google services are free and ad driven. Many applications created by Google directly competed with the applications available on the mobile operating systems of those closed ecosystems. The applications ranged from simple calendars and calculators to navigation with Google Maps—not to mention other services such as Gmail and YouTube.

When Google’s approach to application creation within those closed ecosystems didn’t yield the intended results, Google decided on a different approach—to revamp the entire ecosystem upon which mobile application development was based, hoping to provide a more open environment for users and developers: the Internet model. The Internet model allows users to choose among freeware, shareware, and paid software. This enables free-market competition among services.

Fast forward to today: Google’s Android efforts have come to the forefront. Google’s search engine algorithm has been modified to penalize websites that are not mobile compatible. Mobile search traffic has exceeded that of desktop search traffic and it is only going to continue to grow. Google’s mobile first philosophy surely makes sense.

Introducing the Open Handset Alliance

With its user-centric, democratic design philosophies, Google has led a movement to turn the closely guarded mobile market of the past into one where phone users can move between carriers easily and have unfettered access to applications and services. With its vast resources, Google has taken a broad approach, examining the mobile infrastructure—from the FCC’s wireless spectrum policies to the handset manufacturers’ requirements, application developer needs, and mobile operator desires.

Years ago, Google joined with other like-minded members in the mobile community and posed the following question: What would it take to build a better mobile phone? The Open Handset Alliance (OHA) was formed in November 2007 to answer that very question. The OHA is a business alliance composed of many of the largest and most successful mobile companies on the planet. Its members include chip makers, handset manufacturers, software developers, and service providers. The entire mobile supply chain is well represented.

Andy Rubin has been credited as the father of the Android platform. His company, Android, Inc., was acquired by Google in 2005. Working together, OHA members, including Google, began developing an open-standard platform based on technology developed at Android, Inc., that would aim to alleviate the aforementioned problems hindering the mobile community. The result was the AOSP described previously.

Google’s involvement in the AOSP has been so extensive that who should take responsibility for the Android platform (the OHA or Google) is unclear. Google provides the initial code for the AOSP and provides online Android documentation, tools, forums, the Software Development Kit (SDK), tools, and platforms for developers. Most major Android news originates from Google. The company has also hosted a number of events at conferences (Google I/O, Mobile World Congress, and CTIA Wireless) for millions of dollars in prizes to spur development on the platform. That’s not to say Google is the only organization involved, but it is the driving force behind the platform.

Joining the Open Handset Alliance

The AOSP provides the entire source code for the Android OS as well as instructions for meeting device compatibility requirements, but does not include the source code for many of Google’s proprietary suite of applications. The benefits of joining the Open Handset Alliance include the ability to license Google Mobile Services (GMS), which include proprietary Google applications such as Google Play, YouTube, Google Maps, Gmail, and many other Google branded applications and services. GMS is not included in the AOSP and must be licensed directly from Google. Becoming part of the OHA allows you to bundle GMS on Android-compatible devices.

Manufacturers: Designing Android Devices

More than half the members of the OHA are device manufacturers, such as Samsung, Motorola, Dell, Sony Ericsson, HTC, and LG, as well as semiconductor companies, such as Intel, Texas Instruments, ARM, NVIDIA, and Qualcomm.

The first Android handset to ship—the T-Mobile G1—was developed by handset manufacturer HTC with service provided by T-Mobile. It was released in October 2008. Many other Android handsets were slated for 2009 and early 2010. The platform gained momentum relatively quickly. By the fourth quarter of 2010, Android had come to dominate the smartphone market, gaining ground steadily against competitive platforms such as RIM BlackBerry, Apple iOS, and Windows Mobile.

Google normally announces Android platform statistics at its annual Google I/O conference each year and at important events, such as financial earnings calls. As of May 2015, Android devices were being shipped to more than 130 countries, and Google Play had more than 1 billion active users, with 50 billion app installs in the previous 12 months. The advantages of widespread manufacturer and carrier support appear to be really paying off at this point.

Manufacturers continue to create new generations of Android devices—from phones and tablets with HD displays, to watches for enhancing your mobile experience or managing your fitness level, to dedicated e-book readers, to full-featured televisions, netbooks, integration with automobiles, and almost any other “smart” device you can imagine.

Mobile Operators: Delivering the Android Experience

After you have developed the devices, you have to get them out to the users. Mobile operators from North, South, and Central America as well as Europe, Asia, India, Australia, Africa, and the Middle East have joined the OHA, ensuring a worldwide market for the Android movement. With nearly 1 billion subscribers alone, telephony giant China Mobile is a founding member of the alliance.

Much of Android’s success is also due to the fact that many Android handsets don’t come with the traditional smartphone price tag—quite a few are offered free with activation by carriers. Competitors such as the Apple iPhone have struggled to provide competitive offerings at the low end of the market. For the first time, the average Jane or Joe can afford a feature-full smart device. We’ve heard so many people, from waitstaff to grocery store clerks, say how much their lives have changed for the better after receiving their first Android phone. This phenomenon has only added to Android’s status.

Manufacturers have contributed significantly to the growth of Android. In July 2015, according to International Data Corporation (IDC), Samsung shipped 73.2 million smartphones worldwide in the second quarter of 2015 (http://www.idc.com/getdoc.jsp?containerId=prUS25804315), with the majority of those devices most likely powered by Android.

Google has also created its own Android brand known as Nexus. There are currently multiple devices that have been introduced through the Nexus line—the 4, 5, 6, 7, 9, 10, and Player—each created in partnership with the manufacturers LG (4, 5), Motorola (6), ASUS (7, Player), HTC (9), and Samsung (10). The Nexus devices provide the full, authentic Android experience as Google intends. Many developers use these devices for building and testing their applications because they are the only devices in the world that receive the latest Android operating system upgrades as they are released. If you, too, would like your applications to work on the latest Android operating system version, you should consider investing in one or more of these devices when they become available.

Apps Drive Device Sales: Developing Android Applications

When users acquire Android devices, they need those killer apps, right?

Initially, Google led the pack in developing Android applications. It also developed the first successful distribution platform for third-party Android applications, originally called the Android Market, now known as Google Play. Google Play remains the primary method by which users download apps, but it is no longer the only distribution mechanism for Android apps.

As of May 2015, there have been more than 50 billion application installations from Google Play within the previous 12 months. This takes into account only applications published through this one app store—not the many other applications sold individually or on other app markets across the globe. These numbers also do not take into account all the Web applications that target mobile devices running the Android platform. This opens up even more application choices for Android users and more opportunities for Android developers.

Google Play has been working to increase the exposure and sales of game applications and has provided the Play Game Services SDK. This SDK allows developers to add real-time social features to games, and application programming interfaces (APIs) for implementing leaderboards and achievements to help drive new users to applications, while continuing to engage existing users. An effort to help drive sales of content has also been undertaken. Users are always looking for new music, movies, TV shows, books, magazines, and more, and Google Play’s focus on content has placed it in a position to keep up with user demand for such services.

Taking Advantage of All Android Has to Offer

Android’s open platform has been embraced by much of the mobile development community—extending far beyond the members of the OHA.

As Android devices and applications have become more readily available, many other mobile operators and device manufacturers have jumped at the chance to sell Android devices to their subscribers, especially given the cost benefits compared to the older proprietary platforms. The Android platform’s open standard has resulted in reduced operator costs in licensing and royalties, and we are now seeing a migration to more open devices. The market has cracked wide open; new types of users are able to consider smartphones for the first time. Android is well suited to fill this demand.

Android: Where We Are Now

Android continues to grow at an aggressive rate on all fronts (devices, developers, and users). Lately, the focus has been on several specific topics:

Image Upgrades to competitive hardware and software features: The Android SDK developers have focused on providing APIs for features that are not available on competing platforms to move Android ahead in the market. For example, recent releases of the Android SDK have featured significant improvements to Notifications to bring you the information that matters most to you when you need it.

Image Expansion beyond phones and tablets: Smartwatch usage is on the rise with Android users. There are many new Android Wear devices on the market that come in many different sizes and form factors. Hardware manufacturers are even using Android for gaming consoles, TVs, and dashboards for automobiles, in addition to many other types of devices that require an operating system. Google has even announced Project Brillo, a version of Android designed for the Internet of Things (IoT), along with Weave, an IoT protocol for connecting these devices.

Image Improved user-facing features: The Android development team has shifted its focus from feature implementation to providing user-facing usability upgrades and “chrome.” It has invested heavily in creating a smoother, faster, more responsive user interface, in addition to updating its design documentation with excellent training in best practices for developers to follow. Following these principles should help any application increase usability.


Image Note

Some may wonder about various legal battles surrounding Android that appear to involve almost every industry player in the mobile market. Although most of these issues do not affect developers directly, some have—in particular, those dealing with in-app purchases. This is typical of any popular platform. We can’t provide any legal advice here. What we can recommend is keeping informed on the various legal battles and hope they turn out well, not just for Android, but for all platforms they impact.


Android Platform Uniqueness

The Android platform itself is hailed as “the first complete, open, and free mobile platform.”

Image Complete: The designers took a comprehensive approach when they developed the Android platform. They began with a secure operating system and built a robust software framework on top that allows for rich application-development opportunities.

Image Open: The Android platform is provided through open-source licensing. Developers have unprecedented access to the device features when developing applications.

Image Free: Android applications are free to develop. There are no licensing fees for developing on the platform, no required membership fees, no required testing fees, and no required signing or certification fees. Android applications can be distributed and commercialized in a variety of ways. There is no cost for distributing your applications on your own, and there are app stores that do not require fees for publishing your application for download. But to publish your applications on Google Play requires registration and paying a small, one-time $25 fee. (The term “free” implies there might actually be costs for development, but they are not mandated by the Android platform. Costs for designing, developing, testing, marketing, and maintaining are not included. If you provide all of these, you may not be laying out cash, but there is a cost associated with them. The $25 developer registration fee is designed to encourage developers to create quality applications for Google Play.)

Android: The Code Names

The Android mascot is a little green robot, shown in Figure 1.1. This little robot is often used to depict Android-related materials.

Image

Figure 1.1 The official Android mascot.

Since the Android 1.0 SDK was released, Android platform development has continued at a fast and furious pace. For quite some time, a new Android SDK came out every couple of months! In typical tech-sector jargon, each Android SDK has had a project name. In Android’s case, the SDKs are named alphabetically after sweets.

Free and Open Source

Android is an open-source platform. Neither developers nor device manufacturers pay royalties or license fees to develop for the platform.

The underlying operating system of Android is licensed under GNU General Public License Version 2 (GPLv2), a strong “copyleft” license where any third-party improvements must continue to fall under the open-source licensing agreement terms. The Android framework is distributed under the Apache Software License (ASL/Apache2), which allows for the distribution of both open- and closed-source derivations of the source code. Platform developers (device manufacturers especially) can choose to enhance Android without having to provide their improvements to the open-source community. Instead, platform developers can profit from enhancements such as device-specific improvements and redistribute their work under whatever licensing they want.

Android application developers have the ability to distribute their applications under whatever licensing scheme they prefer, too. They can write open-source freeware or traditional licensed applications for profit and everything in between.

Familiar and Inexpensive Development Tools

Unlike some proprietary platforms that require developer registration fees, vetting, and expensive compilers, there are no up-front costs to developing Android applications.

Freely Available Software Development Kit

The Android SDK, tools, and platforms are freely available. Developers can download the Android SDK from the Android website after agreeing to the terms and conditions of the Android Software Development Kit License Agreement.

Familiar Language, Familiar Development Environments

Developers now have access to an official integrated development environment (IDE) for Android application development, Android Studio, which comes bundled with the Android SDK tools, the most recent Android Platform, and the most recent Android emulator system image with Google APIs. Android Studio is based on the free Community Edition of IntelliJ IDEA, developed by the company JetBrains s.r.o.

Before Android Studio became the official IDE for Android development, many developers chose to use the popular and freely available Eclipse IDE to design and develop Android applications. Eclipse has been one of the most popular IDEs for Android development, and the Android Developer Tools (ADT) plugin has been available for facilitating Android development with Eclipse.

You may also choose to use the Android SDK tools from the command-line as a stand-alone application, without being tied to a particular IDE, or if you prefer running command-line build scripts.

Android Studio is the recommended IDE for Android application development and is supported on the following operating systems:

Image Windows 2003, Vista, 7, and 8 (32-bit or 64-bit)

Image Mac OS X 10.8.5 up to 10.9

Image Linux GNOME or KDE desktops (Tested on Ubuntu Linux 14.04 64-bit)

Reasonable Learning Curve for Developers

Android applications are written in a well-respected programming language: Java. The Android application framework includes traditional programming constructs, such as threads and processes and specially designed data structures to encapsulate objects commonly used in mobile applications. Developers can rely on familiar class libraries such as java.net and java.text. Specialty libraries for tasks such as graphics and database management are implemented using well-defined open standards such as OpenGL Embedded Systems (OpenGL ES) and SQLite.

Enabling Development of Powerful Applications

In the past, device manufacturers often established special relationships with trusted third-party software developers (OEM/ODM relationships). This elite group of software developers wrote native applications, such as messaging and Web browsers that shipped on the device as part of its core feature set. To design these applications, the manufacturer would grant the developer privileged inside access to and knowledge of the internal software framework and firmware.

On the Android platform, there is no distinction between native and third-party applications, thus helping to maintain healthy competition among application developers. All Android applications use the same APIs. Android applications have unprecedented access to the underlying hardware, allowing developers to write much more powerful applications. Applications can be extended or replaced altogether.

Rich, Secure Application Integration

One of the Android platform’s most compelling and innovative features is well-designed application integration. Android provides all the tools necessary to build a better “mousetrap,” if you will, by allowing developers to write applications that seamlessly leverage core functionality such as Web browsing, contact management, and messaging. Applications can also become content providers and share their data with each other in a secure fashion.

No Costly Obstacles for Development

Android applications require none of the costly and time-intensive testing and certification programs that other platforms such as iOS do. To create Android applications, there is no cost whatsoever other than your time. All you need is a computer, an Android device, a good idea, and an understanding of Java.

If you want to publish applications within Google Play, a one-time, low-cost ($25) developer fee is required, but you may choose to publish your application in an app store that does not require a developer fee for publishing or you may host the application for download on your own.

A “Free Market” for Applications

Android developers are free to choose any kind of revenue model they want. They can develop freeware, shareware, trial-ware or ad-driven applications, and paid applications. Android was designed to fundamentally change the rules about what kind of mobile applications could be developed. On mobile platforms preceding Android, developers faced many restrictions that had little to do with the application’s functionality or features such as:

Image Store limitations on the number of competing applications of a given type

Image Store limitations on pricing, revenue models, and royalties

Image Operator unwillingness to provide applications for smaller demographics

With Android, developers can write and successfully publish any kind of application they want. Developers can tailor applications to small demographics, instead of just large-scale moneymaking markets often insisted on by mobile operators. Vertical market applications can be deployed to specific, targeted users.

Because developers have a variety of application distribution mechanisms to choose from, they can pick the methods that work for them instead of being forced to play by others’ rules. Android developers can distribute their applications to users in a variety of ways:

Image Google developed Google Play (formerly the Android Market), a generic Android application store with a revenue-sharing model. Google Play also has a Web store for browsing and buying apps online. Google Play also sells movies, music, and books, so your application will be in good company.

Image Amazon Appstore for Android launched in 2011 with a lineup of exciting Android applications using its own billing and revenue-sharing models.

Image Numerous other third-party application stores are available. Some are for niche markets; others cater to many different mobile platforms.

Image Developers can come up with their own delivery and payment mechanisms, such as distributing from a website or within an enterprise.

Mobile operators and carriers are still free to develop their own application stores and enforce their own rules, but these will no longer be the only opportunities developers have to distribute their applications. Be sure to read any application store’s agreements carefully before distributing your applications on them.

A Growing Platform

Early Android developers have had to deal with the typical roadblocks associated with a new platform: frequently revised SDKs, lack of good documentation, market uncertainties, and mobile operators and device manufacturers that have been extremely slow in rolling out new upgrades of Android, if ever. This means that Android developers often need to target several different SDK versions to reach all users. Luckily, the continuously evolving Android SDK tools have made this easier than ever, and now that Android is a well-established platform, many of these issues have been ironed out. The Android forum community is lively, friendly, and very supportive when it comes to helping one another over these bumps in the road.

Each new version of the Android SDK has provided a number of substantial improvements to the platform. In recent revisions, the Android platform has received some much-needed enhancements in terms of visual appeal, performance, and user experience. Popular types of devices such as smartwatches and TVs are now fully supported by the platform, in addition to new categories such as automobiles.

Although most of these upgrades and improvements were welcome and necessary, new SDK versions often cause some upheaval within the Android developer community. A number of published applications have required retesting and resubmission to Google Play to conform to new SDK requirements, which are rolled out to select Android devices in the field as a firmware upgrade, rendering older applications obsolete and sometimes unusable.

Although these pains are expected, and most developers have endured them, it’s important to remember that Android was a latecomer to the mobile marketplace compared to the iOS platform. The Apple App Store boasts many applications, but users demand these same applications on their Android devices. Few developers can afford to deploy exclusively to one platform or the other—they must support both.

The Android Platform

Android is an operating system and a software platform upon which applications are developed. A core set of applications for everyday tasks, such as Web browsing and email, are included on Android devices.

As a product of the OHA’s vision for a robust and open-source development environment for mobile, Android is a leading development platform. The platform was designed for the sole purpose of encouraging a free and open market that users might want to have and software developers might want to develop for. So far the platform has lived up to that potential.

Android’s Underlying Architecture

The Android platform is designed to be more fault tolerant than many of its predecessors. The device runs a Linux operating system upon which Android applications are executed in a secure fashion. Each Android application runs in its own Application Sandbox (see Figure 1.2). Android applications are managed code; therefore, they are much less likely to cause the device to crash, leading to fewer instances of device corruption (also called “bricking” the device, or rendering it useless).

Image

Figure 1.2 Diagram of the Android platform architecture.

The Linux Operating System

The Linux kernel handles core system services and acts as a hardware abstraction layer (HAL) between the physical hardware of the device and the Android software stack.

Some of the core functions the kernel handles include

Image Enforcement of application permissions and security

Image Low-level memory management

Image Process management and threading

Image The network stack

Image Display, keypad input, camera, Wi-Fi, Flash memory, audio, binder interprocess communication (IPC), and power-management driver access

Android Runtime (ART)

Each Android application runs in a separate process, within its own Application Sandbox. The Android Runtime (ART) is the runtime successor of Dalvik. One of the main feature improvements introduced by ART is ahead-of-time compilation (AOT) rather than the just-in-time compilation (JIT) of Dalvik. With ART, applications are compiled during installation. The compiled files are stored on the device as an executable without requiring compilation prior to launching the application. On the other hand, Dalvik would compile application files prior to launching the application. ART was officially introduced in Android 5.0, and brings significant performance enhancements not previously available with Dalvik.

Security and Permissions

The integrity of the Android platform is maintained through a variety of security measures. These measures help ensure that the user’s data is secure and that the device is not subjected to malware or misuse.

Applications as Operating-System Users

When an application is installed, the operating system creates a new user profile associated with the application. Each application runs as a different user, with its own private files on the file system, a user ID, and a secure operating environment.

The application executes in its own process within its own Application Sandbox and under its own user ID on the operating system.

SELinux Kernel Security Module

Android 4.3 introduced a modified version of the Security-Enhanced Linux (SELinux) kernel module. This edition provides enhanced security for the Android OS and further confines applications to their own sandbox while enforcing mandatory access control (MAC) over all processes.

Explicitly Defined Application Permissions

To access shared resources on the system, Android applications request registration for the specific privileges they require. Some of these privileges enable the application to use device functionality to make calls, access the network, and control the camera and other hardware sensors. Applications also require permission to access shared data containing private and personal information, such as user preferences, the user’s location, and contact information.

Applications might also enforce their own permissions by declaring them for other applications to use. An application can declare any number of different permission types, such as read-only or read-write permissions, for finer control over the application.

Android 6.0 (API Level 23) introduced a streamlined permission process. Rather than requiring users to grant all permissions upon application installation, you are now able to request permissions at runtime when your application actually needs access to a particular permission. Permissions with a protection level of normal are granted at installation and any permission that has a protection level other than normal must be requested at runtime.

Application Signing for Trust Relationships

All Android application packages are signed with a certificate, so users know that the application is authentic. The private key for the certificate is held by the developer. This helps establish a trust relationship between the developer and the user. It also enables the developer to control which applications can grant access to one another on the system. No certificate authority is necessary; self-signed certificates are acceptable.

Multiple Users and Restricted Profiles

Android 4.2 (API Level 17) brought support for multiple user accounts on shareable Android devices such as tablets. With the new release of Android 4.3 (API Level 18), primary device users are now able to create restricted profiles for limiting a user profile’s access to particular applications. Developers may also leverage restricted profile capabilities in their applications to provide primary users the ability to further prohibit particular device users from accessing specific in-app content.

Google Play Developer Registration

To publish applications on Google Play, developers must create a developer account. Google Play is managed closely and no malware is tolerated.

Exploring Android Applications

The Android SDK provides an extensive set of APIs that are both modern and robust. Android device core system services are exposed and accessible to all applications. When granted the appropriate permissions, Android applications can share data with one another and access shared resources on the system securely.

Android Programming Language Choices

Android applications are written in Java. For now, the Java language is the developer’s only choice for accessing the entire Android SDK.


Image Tip

There has been some speculation that other programming languages, such as C++, might be added in future versions of Android. If your application must rely on native code in another language such as C or C++, you might want to consider integrating it using the Android Native Development Kit (NDK).


You can also develop mobile Web applications that will run on Android devices. These applications can be accessed through an Android browser application, or an embedded WebView control within a native Android application (still written in Java). This book focuses on Java application development. You can find out more about developing Web applications for Android devices at the Android developer website: http://d.android.com/guide/webapps/index.html.

Got a Flash app you want to deploy to the Android platform? Check out Adobe’s AIR support for the Android platform. Users install the Adobe AIR application from the Google Play store and then load their compatible applications using it. For more information, see the Adobe website: http://adobe.com/devnet/air/air_for_android.html.

Developers even have the option to build applications using certain scripting languages. There is an open-source project that is working to use scripting languages such as Python and others as options for building Android applications, but the project has not been updated in quite some time. For more information, see the android scripting project: https://github.com/damonkohler/sl4a. As with Web apps and Adobe AIR apps, developing SL4A applications is outside the scope of this book.

No Distinctions Made between Native and Third-Party Applications

Unlike other mobile development platforms, the Android platform makes no distinction between native applications and developer-created applications. Provided they are granted the appropriate permissions, all applications have the same access to core libraries and the underlying hardware interfaces.

Android devices ship with a set of native applications such as a Web browser and contact manager. Third-party applications might integrate with these core applications, extend them to provide a rich user experience, or replace them entirely with alternative applications. The idea is that any of these applications is built using the exact same APIs available to third-party developers, thus ensuring a level playing field, or as close to one as we can get.

Note that although this has been Google’s line since the beginning, there are some cases where Google has used undocumented APIs. Because Android is open, there are no private APIs. Google has never blocked access to such APIs but has warned developers that using them may result in incompatibilities in future SDK versions. See the blog post at http://android-developers.blogspot.com//2011/10/ics-and-non-public-apis.html for some examples of previously undocumented APIs that have become publicly documented.

Commonly Used Packages

With Android, mobile developers no longer have to reinvent the wheel. Instead, developers use familiar class libraries exposed through Android’s Java packages to perform common tasks involving graphics, database access, network access, secure communications, and utilities. The Android packages include support for the following:

Image A wide variety of user interface controls (buttons, spinners, text input)

Image A wide variety of user interface layouts (tables, tabs, lists)

Image Integration capabilities (notifications, widgets)

Image Secure networking and Web browsing features (SSL, WebKit)

Image XML support (DOM, SAX, XML Pull Parser)

Image Structured storage and relational databases (App Preferences, SQLite)

Image Powerful 2D and 3D graphics (including SGL, OpenGL ES, and RenderScript)

Image Multimedia frameworks for playing and recording stand-alone or network streaming (MediaPlayer, JetPlayer, SoundPool, AudioManager)

Image Extensive support for many audio and visual media formats (MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG)

Image Access to optional hardware such as location-based services (LBS), USB, Wi-Fi, Bluetooth, NFC, and hardware sensors

Android Application Framework

The Android application framework provides everything necessary to implement an average application. The Android application lifecycle involves the following key components:

Image Activities are functions that the application performs.

Image Fragments are reusable and modular sections of activities.

Image Loaders are for loading data asynchronously into fragments or activities.

Image Groups of views define the application’s layout.

Image Intents inform the system about an application’s plans.

Image Services allow for background processing without user interaction.

Image Notifications alert the user when something interesting happens.

Image Content providers facilitate data transmission among different applications.

Android Platform Services

Android applications can interact with the operating system and underlying hardware using a collection of managers. Each manager is responsible for keeping the state of some underlying system service. For example:

Image The LocationManager facilitates interaction with the location-based services available on the device.

Image The ViewManager and WindowManager manage display and user interface fundamentals related to the device.

Image The AccessibilityManager manages accessibility events, facilitating device support for users with physical impairments.

Image The ClipboardManager provides access to the global clipboard for the device, for cutting and pasting content.

Image The DownloadManager manages HTTP downloads in the background as a system service.

Image The FragmentManager manages the fragments of an activity.

Image The AudioManager provides access to audio and ringer controls.

Google Services

Google provides APIs for integrating with many different Google services. Prior to the addition of many of these services, developers would need to wait for mobile operators and device manufacturers to upgrade Android on their devices in order to take advantage of many common features such as maps or location-based services. Now developers are able to integrate the latest and greatest updates of these services by including the required SDKs in their application projects. Some of these Google services include:

Image Maps

Image Places

Image Play Game services

Image Google Sign-In

Image In-app Billing and Subscriptions

Image Google Cloud Messaging

Image Mobile App Analytics SDK

Image AdMob Ads

Android beyond the OHA and GMS

One of the primary benefits for device manufacturers becoming members of the OHA is the ability to license the GMS suite of Google branded applications such as Google Play. GMS provides features and capabilities not found on devices without GMS. With that said, there are other popular versions of Android not associated with the OHA and therefore they do not have access to GMS without resorting to aftermarket installations. Just because a device based on a custom fork of Android is not part of the OHA, and does not include GMS or Google Play, does not mean you should overlook supporting your applications on those devices. Here are some areas of interest that involve custom forks of Android.

Amazon Fire OS

Amazon has created its own version of Android named Fire OS. Fire OS is a fork of the AOSP that is installed on all Amazon Fire branded devices, such as the Fire Phone, Fire Tablet, and Fire TV. Recently, Amazon released the Fire OS 5 developer preview that is based on Android Lollipop.

According to a report by Strategy Analytics, Inc., there are close to 4.5 million Amazon Fire TVs that have shipped since launch (http://www.prnewswire.com/news-releases/amazon-fires-to-the-top-of-the-us-digital-media-streamer-market-says-strategy-analytics-300094475.html). With millions of devices available, supporting your Android applications on Amazon Fire OS is definitely worth consideration.

You can learn more about the Amazon Fire OS version of Android here: https://developer.amazon.com/public/solutions/platforms/android-fireos.

Cyanogen OS and CyanogenMod

Another version of Android to keep an eye on is Cyanogen OS. Cyanogen OS is based on the CyanogenMod project that is a community-driven fork of the Android OS, without GMS, although there are aftermarket instructions and tools provided by the user community for installing apps such as Google Play. The Cyanogen, Inc., blog (https://cyngn.com/blog/an-open-future) boasts having over 50 million users in over 190 countries running different versions of CyanogenMod. CyanogenMod is classified as replacement firmware that requires manual installation by a user, for replacing the stock firmware that comes bundled when purchasing a device. Cyanogen OS, on the other hand, is stock firmware that will come preinstalled on Android devices.

Cyanogen, Inc., the company behind Cyanogen OS, is working to create a competing Android ecosystem to that of Google. Currently, Cyanogen, Inc., has received $80 million in venture-capital financing from investors such as Qualcomm Incorporated, Twitter Ventures, Rupert Murdoch, Andreesen Horowitz, and Tencent, just to name a few.

You can learn more about CyanogenMod at http://www.cyanogenmod.org and Cyanogen OS at https://cyngn.com.

Maker Movement and Open-Source Hardware

Another area to keep an eye on is the “Maker Movement,” which is a community of do-it-yourself technology hobbyists, often referred to as “Makers.” A subculture of this community involves projects that are based on open-source hardware. Similar to the beginnings of the open-source software movement, the hardware industry has been experiencing similar open-source trends amongst enthusiasts—mainly in the area of electronics and printed circuit board (PCB) design. The barriers to entry for designing sophisticated electronic devices such as computers, laptops, tablets, or devices for IoT seem to be limited only to one’s imagination and the desire to innovate.

Major hardware-component companies that have traditionally guarded electronic PCB designs are now realizing the potential for innovation by open-sourcing some designs. Processor manufacturers such as Intel, as well as other companies that license and manufacture components based on the ARM processor, have been releasing open-source PCB designs and providing full PCB schematics with the list of required components for completing the circuit. There is an incentive for component manufacturers to provide working PCB designs to help drive sales of those components.

Quite a few companies that manufacture ARM processors have developed open-source PCBs—for devices like tablets—with Android as the OS. This makes designing a sophisticated device—a tablet running Android—accessible to anyone capable of working with a PCB design. PCB software design tools—such as Altium Designer—are used for working with PCB designs.

Powerful tools, combined with open-source PCB designs and the AOSP, may bring about new generations of devices that we are not yet capable of envisioning. The future for Android application development sure looks bright and the possibility for developing innovative applications for Android seems nearly limitless.

Maintaining Awareness

Although this book is about developing Android applications, we wanted to provide background of the overall Android ecosystem—as we see it. We think it is always a good idea to maintain awareness about what is occurring in the ever-expanding Android ecosystem, as these happenings affect everyone involved. There are many exciting occurrences for Android worth following today, and hopefully there will be many more to come.

Summary

Android software development has evolved rapidly over the last few years. Android has become a leading mobile development platform, building on past successes and avoiding the past failures of other platforms. Android was designed to empower the developer to write innovative applications. The platform is open source, with no up-front fees, and developers enjoy many benefits over other competing platforms. There are also a few promising areas of the Android ecosystem to watch. Now it’s time to dive deeper into application development so you can evaluate what Android can do for you.

Quiz Questions

1. What does the acronym AOSP stand for?

2. True or false: Joining the Open Handset Alliance allows device makers to bundle Google Mobile Services.

3. What was the name of the company that Google purchased that is credited for developing much of the technology used in the Android operating system?

4. What was the first Android device called? Which manufacturer created it? Which mobile operator sold it?

5. What is the name of the Amazon OS based on Android?

Exercises

1. Describe the benefits of Android being open source.

2. In your own words, describe Android’s underlying architecture.

3. Familiarize yourself with the Android documentation, which can be found at http://d.android.com/index.html.

References and More Information

Android Developers:

http://d.android.com/index.html

Android Open Source Project:

https://source.android.com/index.html

Open Handset Alliance:

http://openhandsetalliance.com

Official Android Developers Blog:

http://android-developers.blogspot.com

This book’s blog:

http://introductiontoandroid.blogspot.com

Intel Open Source: Android on Intel Platforms:

https://01.org/android-IA

ARM Connected Community: Android Community:

http://community.arm.com/groups/android-community

Altium Designer:

http://www.altium.com/altium-designer/overview

Wikipedia: Maker Culture:

https://en.wikipedia.org/wiki/Maker_culture

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

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