Public-oriented mobile technology: comprehensive introduction to Android (1)
Enter the mobile world of Android and build your first application
The mobile field is a promising field. For developers who want to enter this field, Android is an exciting platform. This series will first introduce Android and specifically target Java™The developer made changes. We will understand the three-tier version of Android and its importance), and then set up your development environment and build your first Android Application.
About this series:Mobile Application release is showing explosive growth, while mobile development technology is at the right time. This series of articles will introduce the development of this field to developers with programming experience and just getting started with the mobile field. This series first uses Java code to write local applications, and then expands your toolbox, including the JVM language, script framework, HTML5/CSS/JavaScript, and third-party tools. You will gradually master the required skills to meet the needs of almost all mobile development scenarios.
Recently, the rapid development of mobile technology has even surprised people in the industry. In an interview in September 2012, Apple CEO Tim Cook expressed this point when discussing the success of the iPad. Selling 67 million iPad in just two years is definitely an outstanding performance. Cook compared this number based on historical sales, "this sales volume is equivalent to our Mac 24-year sales volume, iPod 5-year sales volume, and iPhone 3-year sales volume ".
If iOS has achieved great success, the Java-centered Android platform naturally performs well. According to a recent statement by Google, 2008 Android devices have been activated since Android was officially released in 0.5 billion, and about 1.3 million devices are activated every day. According to reports, Apple's iTunes App Store and Google Play have a total of at least 1400000 applications and more than 60,000,000,000 mobile applications downloaded.
Activating all these mobile devices means there are new application sales opportunities and a larger mobile development technology market. Android is a good start for developers who want to quickly build mobile skills. If you can write Java code and other JVM languages, you can focus the initial learning curve on mobile deployment requirements. The diversity of Android means you can easily use and try some newer technologies, such as HTML5 and PhoneGap. And Google Play is included in its platform's universality) will ensure that your production applications can be widely released.
Public-oriented mobile technologyThe first article in the series will briefly introduce Android. First, we will understand the very sophisticated Android version system, and then set up a development environment to start building your first application.
Android boom
The distribution speed of Android devices exceeds any other mobile platform, making Android a perfect choice for your first mobile development journey, especially when you are a Java developer. One drawback of the massive adoption of Android is storage fragmentation, which brings great challenges to application testing. The cruel reality facing most developers is that they cannot test applications by combining all Android devices and OS configuration files. In fact, testing in an economic and efficient way is gradually becoming a new service industry ). Later articles will discuss some technical issues, including porting to multiple Android configuration files and testing Java-based tools for Android mobile apps. This article will learn about Android version control. You can develop this platform by understanding version control.
Three ways to enter the mobile field:At a higher level, the mobile ecosystem has three major development platforms: native, Web, and hybrid development platforms.
-
Compared with the other two, the local platform can generate applications with superior appearance and performance. The disadvantage of building a local application is that you have to write different code libraries for each platform.
-
Web mobile applications are usually written in HTML5, CSS, and JavaScript. You can write a Web mobile application and run it on multiple platforms, but the appearance and performance of the application may be inferior to that of the local application.
-
The hybrid tools and frameworks make up for these shortcomings because they combine the simplicity and universality of Web applications with the appearance of local applications. Developers always argue about which platform is better or someone calls it the "big debate on mobile applications"), but in fact each platform has its own merits.
This series of articles will discuss these three platforms.
Android version control
Android OS versions are continuous, such as 1.6, 2.1, and 4.2. The version name follows the name of the dessert menu: Donut, Eclair, and Jelly Bean. When someone references Jelly Bean in the Android environment, it actually refers to Android 4.2. The Android version can also be described at the API level, represented by consecutive ascending integers. Therefore, Android API level 17 refers to Android 4.2, that is, Jelly Bean.
If you think these names are not easy to understand, you are not the only one who has such ideas. However, it is very important to understand these names, because these three versions are often used in different ways.
In terms of supporting different Android versions, most Java developers must completely change their previous thinking. The Java platform is considered as a server-side technology. users' access to this technology is usually through Web pages. If the Web page is browsed, visitors to the Web page will not care about which Java version your application is running. However, for Android, this means that the application is out of the server protection and runs on devices that you cannot control.
Many potential users of the application upgrade to the new Android OS only when the old device is unavailable. Which Android operating system is supported is very important. Although the latest Android version is 4.2, almost half of Android devices still support Android 2.3.x. Applications written for Android 3.1 can run on new versions such as Android 4.2, but cannot run on old versions such as Android 2.3. Therefore, if you want to implement a wider range of releases, the best choice is for older operating systems.
One drawback of a platform that targets the old system and is more widely released is that new versions always offer new features and you may want to use these features in your own applications. If you are lucky, the Android development team will release a compatible library. You can use these new features on the old version.
Use Android and Eclipse ADT to create and run applications
At the beginning of the Android introduction, I will help you create a simple Android Application as quickly as possible. You will use the Android 4.2 and Eclipse Android Development Tools (ADT) plug-ins to create a Java-based Hello World application.
Android-compatible IDE:When developing mobile applications for Android, you can use Java tools and frameworks that you are already familiar. For example, the two most popular Java Development ides are Eclipse and IntelliJ, both of which support Android. Android and Eclipse are closely linked. The plug-in provided by Android can easily implement the "Build-test-deployment" cycle of Android applications. The example in this article is built using Eclipse, but you can also build it using IntelliJ.
There are two ways to establish a development environment for Android. Developers new to Eclipse and Android can download the ADT (Android Developer Tools) Bundle first. The ADT Bundle is bound with an Android SDK and an Eclipse version, with the ADT plug-in installed. This package helps you quickly and easily use Android.
If Eclipse has been installed on a desktop and configured, download and install the Android SDK manually. The basic Android SDK contains some system tools that simplify Android development, but it lacks the Android library required to develop a specific Android version. After downloading the basic Android SDK for your operating system, you can access the tool directory of the SDK installation directory and runListing 1Android script in.
Listing 1. Start Android SDK Manager
- ~/Development/tools/android/android-sdk-mac_x86/tools$>./android
This script starts Android SDK Manager. You can download various Android versions and libraries and create simulated programs or virtual device instances. The Android SDK Manager opens a window showing a list of long options to be downloaded, as shown in figureFigure 1.
Figure 1. SDK Manager
In the check box on the left, select Tools and then Android 4.2 (API 17 ). This folder displays many options. Select the image of SDK Platform and arm eabi v7a System, as shown in figureFigure 2.
Figure 2. Select from SDK Manager
Click Install packages and accept any required licenses. The manager completes the remaining steps.
Create a simulator
Next, create a simulator instance, a virtual device that runs applications. The simulator must be specific to Android, so we will create a simulator instance running Android 4.2.
Start SDK Manager again if it is disabled ). If the Android SDK tool or platform tool has been updated, restart SDK Manager. In the SDK Manager top-level menu, select Tools> Manage AVDs to open a new dialog box about Android Virtual Device Manager, as shown inFigure 3.
Figure 3. Android Virtual Device Manager
This dialog box lists all simulators defined on your machine. The simulator list is empty before the simulator is created. Click New to open the Create a new Android Virtual Device (AVD) dialog box, in which a simulator can be defined. Select Android version 4.2 from the Target drop-down list. In the AVD Name folder, Name the simulator. The Name I use is Android_4.2. When you are ready to test the application, you can use this name to start the simulator from the command line.
Figure 4. Create a new Android Virtual Device
InFigure 4You can see some AVD options, including device type, camera settings, memory and storage. In my example, I selected Galaxy Nexus and used a 200 MB SD card for it. Finally, I selected the Use Host GPU simulation option to improve the performance of the simulator instance.
Click OK to view the new virtual devices listed in the AVD dialog box. Select the device and click Start. A dialog box with startup options is displayed. Now, use the default value and click Launch. The startup time of the simulator instance is long, so you can have a cup of coffee at this time, browse Facebook or update your Twitter status.
Figure 5. New Android device!
After a while, a shiny simulator device is similarFigure 5) Will be displayed on your home screen, which means you can start creating the Android 4.2 Application.