Android 3 SDK Programming For Dummies Cheat Sheet
Android is an open source, Linux- and Java-based, software framework for mobile and portable devices. The Android operating system has a well-designed Java-based SDK to make developing apps straightforward and fun. Before you develop Android 3 applications, get to know Eclipse (an integrated development environment for Java developers) and how to do some common tasks such as creating icons and activities.
Android: Using the Eclipse IDE for Java Development
Nowadays, software tool developers use an Integrated Development Environment (IDE) for easier Java development. The most widely accepted IDE among Java developers is Eclipse. This table gives you quick tips for using the Eclipse IDE to develop Android apps.
|Task||How to accomplish|
|Start a new Android project||From the New Project screen, under Android in the Wizards
panel, select Android Project.
|Create and starting an emulator||From the Window menu, select Android SDK and AVD Manager.
Select Virtual Devices and click on New. Enter a name for the
virtual device, set the target and click on Create AVD. The device
will be created. You will be placed back in the Virtual Devices
screen. From the list of devices, select the device you just
created and click on Start.
|Deploy your app on a device||Right-click on the project that contains the app, select Run
As, and then select Android Application.
|Bring up the logcat window||From the Window menu, select Show View, and then Other. From
the list of views shown, select logcat.
|Debug your application||Declare your application as “debuggable” in its manifest. To do
this in Eclipse, view the Manifest, open the Applications tab, and
set the field named Debuggable to true (or edit the XML directly,
add android:debuggable=“true“ as an attribute to the <application> element). Enable USB
debugging on Windows and Linux (see Google USB
Driver and Using
Hardware Devices). Right-click on the project that contains the
app, select Debug As and then select Android Application
|See what devices are available||From the Window menu, select Show View, and then Other. Select
Android, and then select Devices
|Open the DDMS perspective to browse a device||From the Window menu, select Open Perspective, and then
|Upload a file to a device||Open the DDMS perspective to browse the device. In the File
Explorer tab, click and highlight the directory into which you want
to upload the file. Then select the little icon at the top of the
window whose tooltip says, “Push a file onto the device”.
|Use the profiler||In the Devices view, select the running project. Start the
profiling by clicking on the icon to the left of the Stop sign
(tooltip reads, “Start Method Profiling”).
|Set up an Android Unit Test project||In the Resource or the Java perspective select
File->New->Other-Android Test Project. Set the name of the
Android development project that is being tested.
Mastering Common Tasks of Android App Development
Android app development involves many tasks, including designing and building the core of your application; determining user interface components; and, importantly, making your Android app commercially available to the public. This table is a “how-to” for many of the tasks you perform when developing Android apps.
|Task||How to Accomplish|
|Create string, color, image, audio, and video resources||In the Android project look under the res directory. String and color resources are
placed in the strings.xml file in the
values sub-directory. Images, audio and
video are added in the raw
|Create icons||Icons are added in the drawable
directories. Common icons are placed in res->drawable. Icons for specific screen
resolutions and sizes are placed in the extended drawable directories; drawable-hdpi for high-resolution screens,
drawable-mdpi for medium resolution
screens and drawable-ldpi for low-res
|Create an activity||Create a Java class for the activity that extends android.app.Activity.Activity. Create an entry
for it in the AndroidManifest.xml
|Create the user interface for an activity||Create the layout file for each class in the res->layout
directory. Use setContentView(…) to create and
set the view for the activity. Use findViewById(…) to extract the components of the view.
Activity must implement the onClickListener interface (the onClick(…) method).
|Create a menu for an activity||Define the menu in the res-menu sub-directory of the project.
Implement the onCreateOptionsMenu(Menu
menu) method and the onOptionsItemSelected(MenuItem item).
|Add logging to your application||Use Log.v(…), Log.d(…), Log.i(…), Log.w(…), or Log.e(…) (verbose, debug,
information, warning, and error, respectively). Parameters to each
of these methods are a string tag and a string message.
|Launch a web browser from your app||Use:
Intent LaunchBrowserIntent = new
|Record audio or video||Create an intent using android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION.
Broadcast the event using the startActivityForResult(…). Implement a
protected method onActivityResult(int
requestCode, int resultCode, Intent data) to receive the
result as an intent.
For video, use the same code, but with android.provider.MediaStore.ACTION_VIDEO_CAPTURE.
|Publish to the Android store.||Create a Developer account by clicking on the
http://market.android.com/publish link at the bottom of the home
page of the Android Market. Sign your application using
File→Export→Android→Export Signed Android
Application. Upload your application from the Developer Console of
the Android Market.