Hardware Reference
In-Depth Information
Modding
The devices branded by Google are the better choice for heavy development. There are many devices that can be
made to work with the ADK, but may require modding, also known as rooting . Modding is a great way to achieve
extra functionality in an Android device. Modding is not without risks—for example, so-called bricking , voiding of
warranties, and the possibility of devices becoming unstable are the biggest problems.
If you decide to modify a device, do a sufficient amount of research and weigh the risks and cost before
proceeding. If you're unsure about mods, either don't do them or consult someone who has.
This chapter was developed with a Barnes and Noble NOOK Color running both CyanogenMod 7 (Android 2.3)
and CyanogenMod 9 (Android 4.0), dual-boot from the SD card. CyanogenMod is an aftermarket Android distribution
providing custom ROM for a variety of devices. You can find more information about it at the CyanogenMod web
site ( www.cyanogenmod.com ) . CyanogenMod is developed by the community and has a lot of support, and is one of
the more popular aftermarket Android distributions. You can find great resources for modding and development of
Android systems at the XDA Developers forums ( www.xda-developers.com ) .
I chose the NOOK Color as a development platform because of the cost, ease of modification, and decent
hardware specifications. CyanogenMod 7 for this device had to have a custom kernel compiled with the configure
flag CONFIG_USB_ANDROID_ACCESSORY set during the compile, and the usb.jar libraries added to the system.
CyanogenMod 9 for the NOOK Color can be installed on an 8 GB microSD card and booted—just like having multiple
bootable devices on a normal PC. You don't need a NOOK Color for the examples in this chapter, although you will
need an Android device capable of using the ADK protocols.
Arduino IDE Setup
This chapter will provide an introduction to building a classic Hello World hardware example with an Android twist.
An Android device and an Arduino Mega ADK are needed for the rest of this chapter. Before any programming can
be done, the Android and Arduino environments need to be set up. The Arduino 1.0 IDE (or later) should already be
available, but a library is needed to work with the ADK protocol. The appropriate library is available from the Arduino
labs web site ( http://labs.arduino.cc/uploads/ADK/GettingStarted/ArduinoADK-beta-001.zip ) .
Contained in the ZIP file are files for Processing and Arduino; you can ignore the Processing folder. In the
Arduino folder are two versions of the library. Extract the folder named UsbHost and the files located in the libraries
folder to the libraries folder for the Arduino IDE. Start or restart the Arduino IDE, finishing the installation of the
new library. Under File Examples UsbHost, examples should now be available. Open the first example and verify
that it can compile. Once finished, the Arduino IDE will be ready to program ADK applications.
You need to set up a development environment to write the Android code and make the installation packages.
Both Processing ( http://processing.org ) and Eclipse ( http://eclipse.org ) can create Android applications.
Programming in Processing is similar to programming Arduino code, but lacks some finesse and control. This chapter
focuses on the Eclipse IDE, which provides greater functionality but is a bit cumbersome. When using Eclipse for
Android development, you need to understand two different styles of code: the main Java-related portion and XML.
The Java-styled code is the grunt of any Android application and is the main programming language; XML is the
fluff that defines the layout, objects, and text that gets displayed. I'll describe the programming methodologies for
application development a bit later in the chapter. If this is your first introduction to Android development, check out
Wallace Jackson's Android Apps for Absolute Beginners (Apress, 2011).
Installing the Eclipse IDE is fairly straightforward. For best results, follow the instructions on the Android
Developers web site for your specific system ( http://developer.android.com/sdk/installing.html ). The
complicated part of the setup is making sure that the ADB functions properly; this may actuality require that you have
root access and that you turn on USB debugging in the device settings. To check if the ADB is working, in a command
prompt change to the platform-tools directory and run the command adb , and the command's help should be
printed to the screen. If the command does not run from any other directory, check to see if the SDK's installation
directory has been added to the environment variables.
 
Search WWH ::




Custom Search