Mastering Common Tasks of Android App Development - dummies

Mastering Common Tasks of Android App Development

By Rajiv Ramnath, Roger Crawfis, Paolo Sivilotti

Part of Android 3 SDK Programming For Dummies Cheat Sheet

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 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
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
Intent(Intent.ACTION_VIEW, theUri);


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 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.