Tuesday, 14 June 2011

ANDROID DEVELOPER TOOLS

The easiest way to start developing Android applications is to download the Android SDK and the Eclipse IDE (see Resources). Android development can take place on Microsoft® Windows®, Mac OS X, or Linux.

This article assumes you are using the Eclipse IDE and the Android Developer Tools plug-in for Eclipse. Android applications are written in the Java language, but compiled and executed in the Dalvik VM (a non-Java virtual machine). Coding in the Java language within Eclipse is very intuitive; Eclipse provides a rich Java environment, including context-sensitive help and code suggestion hints. Once your Java code is compiled cleanly, the Android Developer Tools make sure the application is packaged properly, including the AndroidManifest.xml file.
 
It's possible to develop Android applications without Eclipse and the Android Developer Tools plug-in, but you would need to know your way around the Android SDK.

The Android SDK is distributed as a ZIP file that unpacks to a directory on your hard drive. Since there have been several SDK updates, it is recommended that you keep your development environment well organized so you can easily switch between SDK installations. The SDK includes:

android.jar
    Java archive file containing all of the Android SDK classes necessary to build your application.
documention.html and docs directory
    The SDK documentation is provided locally and on the Web. It's largely in the form of JavaDocs, making it easy to navigate the many packages in the SDK. The documentation also includes a high-level Development Guide and links to the broader Android community.
Samples directory
    The samples subdirectory contains full source code for a variety of applications, including ApiDemo, which exercises many APIs. The sample application is a great place to explore when starting Android application development.
Tools directory
    Contains all of the command-line tools to build Android applications. The most commonly employed and useful tool is the adb utility (Android Debug Bridge).
usb_driver
    Directory containing the necessary drivers to connect the development environment to an Android-enabled device, such as the G1 or the Android Dev 1 unlocked development phone. These files are only required for developers using the Windows platform.
 
Android applications may be run on a real device or on the Android Emulator, which ships with the Android SDK.Android Debug Bridge

The adb utility supports several optional command-line arguments that provide powerful features, such as copying files to and from the device. The shell command-line argument lets you connect to the phone itself and issue rudimentary shell commands. Figure 4 shows the adb shell command against a real device connected to a Windows laptop with a USB cable.Within this shell environment, you can:

    Display the network configuration that shows multiple network connections. Note the multiple network connections:
        lo is the local or loopback connection.
        tiwlan0 is the WiFi connection with an address provisioned by a local DHCP server.
    Display the contents of the PATH environment variable.
    Execute the su command to become the super-user.
    Change the directory to /data/app, where user applications are stored.
    Do a directory listing where you see a single application. Android application files are actually archive files that are viewable with WinZip or equivalent. The extension is apk.
    Issue a ping command to see if Google.com is available.

From this same command-prompt environment, you can also interact with SQLite databases, start programs, and many other system-level tasks. This is fairly remarkable function, considering you're connected to a telephone.

In the next section, you'll create a simple Android application.Coding a basic application

This section provides a whirlwind tour of building an Android application. The example application is about as simple as you can imagine: a modified "Hello Android" application. You'll add a minor modification to make the screen background color all white so you can use the phone as a flashlight. Not very original, but it will be useful as an example. Download the full source code.

To create an application in Eclipse, select File > New > Android project, which starts the New Android Project wizard.

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Online Project management