Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
Twitter logo OReilly Book Cover Art
HomeF.A.Q.
Community
Writing Recipes
Login
Recipe List (303)
Chapter
Id
Published?
Title
Problem
Preface1PPreface

N/A

Preface6PAbout O'Reilly Cookbooks

What is special about the O'Reilly Cookbook Series?

Preface4NAuthor's Guide: How to Write Cookbook Recipes

There should be one place to look for information on writing recipes. In fact there are two. All the information about what to write and how to word it is on the page you are now reading. All information about formatting using our Wiki-subset markup is [[Wiki Markup Subset for Cookbook Site|here].

This page is a work in progress and will grow; if you wrote any other O'Reilly Cookbook (or even read one) please feel free to Comment and we'll incorporate the best comments here.

Preface137NRecommended Android Web Sites

N/A

Preface2NRECIPE WISHLIST (temporary recipe a.k.a. Book Outline)

There are lots of talented developers out there; we just need a way to help them decide what to write about.

Preface5NWiki Markup Subset for Cookbook Site

Every wiki site seems to accept a slightly different subset of the Wiki language originated in 1995 by Ward Cunningham, and later adopted by Wikipedia and others. Here's how this site works in this regard.

Getting Started1939PIntroduction: Getting Started

N/A

Getting Started352PLearning the Java Language

Android apps are written in the Java(tm) programming language before they are converted into Android's own class file format, DEX. If you don't know how to program in Java you will find it hard to write Android apps.

Getting Started545NPreparing the development environment.

Preparing the development environment.

Getting Started236PHello World - Command Line

You want to create a new Android project without using the Eclipse ADT plug-in.

Getting Started4137NHello World - Maven Version

You want to build an Android app using Maven to handle the administrivia.

Getting Started278PHello World - Eclipse Version

You want to use Eclipse to develop your Android application.

Getting Started1321PSet Up an IDE on Windows to Develop for Android

Some owners of Android mobile phones, tablets and other devices may want to develop their own Android applications. They may use a Windows PC, a concise guide to setting up an IDE for that platform is useful.

Getting Started709PAndroid Lifecycle

Android apps do not have a "main" method; you need to learn how they get started and how they stop or get stopped.

Getting Started1841PInstalling .apk files on the emulator

You have an application's .apk file, and want to installing it on the emulator to check out the application, or because an application you are developing requires it.

Getting Started691PInstalling apps onto an Android Emulator

App stores are a huge element of the attraction of modern smartphones. The Android Market is the official one, but you may want to use app stores other than Google's Android App store.

Getting Started682PSharing Java classes from another Eclipse Project

You want to use a class from another project, but don't want to copy-and-paste

Getting Started2514PReferencing libraries to implement external functionality

You need to reference an external library in your Android source project

Getting Started1829PUse SDK Samples to Help Avoid Head Scratching

Sometimes it is a struggle to code up some functionality, especially when the documentation is sketchy or does not provide any examples.

Getting Started1781PKeeping the Android SDK Updated

The SDK must be kept updated to allow App developers to work with the latest APIs on the evolving Android platform.

Getting Started1846PTaking a Screenshot from the Emulator/Android Device

Taking a screen-shot of the application running on an Android Device.

Getting Started281NGetting Screenshots

You need a standard way of getting screenshots for use in the Android Cookbook or any other documentation.

Getting Started1205PProgram: A Simple CountDownTimer example

Require a simple count down timer

Getting Started2106PProgram: Tipster, a tip calculator for the Android OS

A tip calculator is quite a simple application. When you go with friends to a restaurant and wish to divide the check and tip, you simply add the tip percentage to the total and divide by the number of diners. Tipster is an implementation of this in Android, to show a complete application.

Getting Started3427NGetting the source code of Android itself

How did they do that?

Getting Started4213NLearning About Android Releases

You keep hearing about Gingerbread, Ice Cream Sandwiches, and Jelly Beans, and need to know what it all means.

Designing a successful Application2080PIntroduction: Designing a Successful Android application

N/A

Designing a successful Application75PException Handling

Java has a well-defined exception handling mechanism, but it takes some time to learn to use it effectively without frustrating either users or tech support people.

Designing a successful Application1218PAndroid's Application Object as a "Singleton"

In the all too common case when you need to access "global" data from within your Android app, the best solution is to to use subclass android.app.Application and treat it as a Singleton with static accessors.

Designing a successful Application1088PKeeping data when the user rotates the device

When the user rotates the device, Android will normally destroy and re-create the current Activity. You want to keep some data across this destroy-re-create cycle, but all the fields in your activity are lost during it.

Designing a successful Application2688NPreserving Activity State

Users expect Apps to be in the same position as when they were interrupted, e.g. from taking a call. Developers need to know how to restore Activity state.

Designing a successful Application1922PMonitoring the Battery Level of your Android Device

Your long-running application needs a means of detecting the battery level for notifying the user when the battery level goes below a certain threshold.

Designing a successful Application2000PSplash Screens in Android: Method 1

Most applications require an introductory opening screen.

Designing a successful Application2008PSplash Screens in Android: Method 2

Most applications require an introductory opening screen.

Designing a successful Application2043PDesigning a Conference/*Camp/Hackathon App

You want to design an app for use at a Conference, BarCamp, or Hackathon.

Designing a successful Application1503PUsing Google Analytics in Android Application

Often developers want to track their application in terms of features used by users. How can one find which feature is most used by the App's users?

Designing a successful Application2763PA Simple Torch Light

You want to use your smart phone as a torch lamp/flashlight when there is no light or a power failure.

Designing a successful Application2845PAdapting Android Phone Application to Tablet

I have developed an application for my smart phone. Is there a way to run it gracefully on a tablet without any significant changes to my code?

Designing a successful Application2842PFirst Run Preferences

You have an application which collects app usage data anonymously, so you need to make the user aware of this the first time they run the app.

Designing a successful Application2973PFormatting the time and date display

I want to display the date and time in different standard formats. What is the the easiest approach to achieve this?

Designing a successful Application2987PControlling Input with KeyListeners

My application contains a few text boxes in which I want to restrict the users to enter only numbers; also in some cases to only positive numbers or even integers as well as dates. How do I achieve this with minimum efforts?

Designing a successful Application2968PAndroid Application Data Backup

If a user performs a factory reset or converts to a new Android-powered device, the application loses stored data or application settings.

Designing a successful Application2847PWorking Without Tooltips: Use Hints Instead

Android devices can have small screens, there may not be room for help text, and tooltips are not part of the platform.

Designing a successful Application4063NOnboarding - The Welcome Process

Most applications will require some introduction for non-technical users. The "onboarding" process, that of introducing the user and your app to each other, is your chance to inform, to inspire, and to get the user excited about using your app. This is a standard aspect of "user experience" (UX) design, but is often overlooked when technical people design an app.

Designing a successful Application3856NUse Reflection to Safely Access Version-dependent API

You need to access an Android API that was added recently, but still have your app work (possibly with less functionality) on devices running older releases.

Testing1944PIntroduction: Testing

N/A

Testing456PHow to TDD(test driven development) Android App

Lack of mocking support making TDD Android App cumbersome.

Testing1456PSet Up an Android Virtual Device (AVD) for App Testing

Successful Apps must run on a wide range of Android devices and versions.

Testing3369PTest on a huge range of devices with cloud-based testing

You need to test your app on a wide variety of devices.

Testing3352PCreating and Using a Test Project

You need to create and use a new Test Project to test your Android application.

Testing785PHow to troubleshoot "The application has stopped unexpectedly. Please try again"

Your app crashes and you are uncertain as to why.

Testing1906PDebugging using Log.d and LogCat

Many a times even though the Java code compiles without error, running the application crashes giving a 'Force Close' (or similar) error message.

Testing3200PGetting Bug Reports from Users Automatically with BugSense

Users don't necessarily inform you every time your app crashes,and when they do, often important details are omitted. You'd like a service that catches every exception and reports it in detail.

Testing3575PUsing a local runtime application log for analysis of field errors or situations

Users reported something about your App that you don't think should happen, but now that the 'release mode' App is on the market, you have no way to find out whats going on in the users environment and bug reports end up in a 'cannot reproduce' scenario.

Testing2636PActivity LifeCycle Scenarios for Testing

Apps should be resilient to the Activity Lifecycle. Developers need to know how to reproduce different lifecycle scenarios.

Testing1286PKeep Your App Snappy With StrictMode

Making sure your app's GUI is as snappy as possible isn't easy. But with the help of Android's StrictMode it doesn't seem all that bad.

Testing1253PBarrel of Monkeys

Not quite the Turing test, but if your app can pass the monkey test, you deserve a pat on the back.

Testing2347PSending text messages and placing calls between AVDs

You have made an app which needs to place or listen for calls or send or receive text messages and you want to test this.

Testing4233PChecking Android Source Code with Android Lint

Your code looks OK, but you want to see if it passes muster when subjected to expert scrutiny.

Content Providers3109PIntroduction: Content Providers

N/A

Content Providers3112PRetrieving Data from a Content Provider

You want to read from a Content Provider such as Contracts.

Content Providers1558PWriting a Content Provider

Often the application generates data, which can be processed and analyzed by another application. What is the safest way to achieve this, without giving direct access to our application's database?

Content Providers1779PAndroid Remote Service

How to write remote service in the android? How to access it from other application?

Graphical User Interface1054PIntroduction: GUI

N/A

Graphical User Interface10PUser Interface Guidelines

Lots of developers, even good ones, are very bad at user interface design.

Graphical User Interface1272PHandling Configuration Changes by Decoupling View from Model

When your device's configuration changes (most frequently due to an orientation change), your Activity is destroyed and recreated, making state information difficult to maintain.

Graphical User Interface2719NPortrait or Landscape? Both!

An Activity's screen should be useable in both portrait and landscape modes.

Graphical User Interface1397PBasics: A Button with its Click Action Handler

You need to do something when the user presses a Button.

Graphical User Interface2359PFive Ways to Wire Up an Event Listener

Developers need to be familiar with the different ways to code event handlers, they they will come across different methods in tutorials, samples and online snippets.

Graphical User Interface697PUsing CheckBoxes and RadioButtons

You want to offer the user a set of choices that is more limited than a list.

Graphical User Interface1709PEffective UI design using Image Buttons

While building an application, many times the UI design requires the effective use of image buttons. It can save effort compared to text views with descriptive text, since an image can explain the scenario much better than a lot of words.

Graphical User Interface3307NCreating your own Custom Button Style

You need to create your own custom button style for all your application buttons.

Graphical User Interface3100PDrop-down Chooser via the Spinner Class

You want to offer a drop-down choice item.

Graphical User Interface3255PHandle LongPress/LongClick Events

You want to listen for long press / long click events and react to them, without having manually to check for multiple events.

Graphical User Interface3683PBasics: Text Fields with TextView and EditText

You want to display text on the screen, either read-only or editable.

Graphical User Interface2122PConstrain EditText Values with Attributes and the TextWatcher Interface

There is a need to limit the range and type of values being input.

Graphical User Interface2135PImplementing Autocompletion in Android.

Save the user from typing entire words, instead auto-complete the entries.

Graphical User Interface827NAutocompletion with Icons/Images

Searching for items/entries, that can occur in more that a single category. Perform autocompletion and simultaneously make the difference in categories immediately apparent using icons. For example, the term Pain (in bold) occurs in both Symptoms category as well as Reactions category, but also text in the Notes category. Categories:

Symptoms: Pain, Depression, Weakness Reactions: Pain, Inflammation, Itchiness Notes: I had a pain in my buttocks.

Graphical User Interface404PFeed AutoCompleteTextView using a SQLite database query

Although the Android documentation contains a complete working example of using AutoCompleteTextView with an ArrayAdapter, just substituting a SimpleCursorAdapter into the example does not work.

Graphical User Interface2901PTurning Edit Fields into Password Fields

You need to designate an EditText as a password field, so that characters the user types will not be visible to "shoulder surfers".

Graphical User Interface422PChange The Enter Key to "Next" on the Soft Keyboard

Several apps, including the Web Browser and the Contacts app, replace the "Enter" key on the on-screen keyboard with a "Next" key that gives focus to the next data entry view. How do you add this kind of polish to your own apps?

Graphical User Interface2283PProcessing key press events in an Activity.

Intercepting the keys pressed by the user and performing actions corresponding to them.

Graphical User Interface1438PLet Them See Stars: Using RatingBar

You want the user to choose from a number of identical GUI elements in a group to indicate a value such as a "rating" or "evaluation"

Graphical User Interface671PMake a View Shake

You want a View component to shake for a few seconds to catch the user's attention.

Graphical User Interface1242PHaptic Feedback

Building user confidence that their actions had an effect is a requirement for any app on any platform. The canonical example is displaying a progress bar to let users know their action took effect and it's being processed. For touch interfaces this technique still applies, but the advantage of a touch interface is that developers have the opportunity to provide physical feedback, users are capable of actually feeling the device react to their actions.

Graphical User Interface1693PNavigate different activities within a TabView

You want to move from an activity within a tab view to another activity within the same tab.

Graphical User Interface1584PCreating your own Custom Title Bar

You cannot have any buttons or any custom text in the standard title bar.

Graphical User Interface272PFormatting Numbers

You need to format numbers, because the default formatting of Double.toString() and friends do not give you enough control over how the results are displayed.

Graphical User Interface389PFormatting with Correct Plurals

You're displaying something like "Found "+ n + " items", but in English, "Found 1 reviews" is ungrammatical. You want "Found 1 review" for the case n == 1.

Graphical User Interface1670PStart a Second Screen from the First

New App developers need a simple example on how to open another screen, thus understanding how Android handles UI creation.

Graphical User Interface1599PLoading Screen in between two Activities

If you are getting an black screen before loading an activity here's how to avoid it.

Graphical User Interface2144PUsing SlidingDrawer to Overlap Other Components

The proper layout of SlidingDrawer isn't covered to well in the SDK documentation. Here's how to use the control to overlay other components in a layout. As well as how to position elements in the underlying layout to avoid the drawer handle.

Graphical User Interface996PCustomize the SlidingDrawer component to animate/transition from the top down.

You want to customize the SlidingDrawer component to animate/transition from the top down.

Graphical User Interface983NSlidingDrawer Overlapping other UI components

You want the SlidingDrawer to overlap other UI components eg. ListView

Graphical User Interface2318PAdd a Border with Rounded Corners to a Layout

There is a need to put a border around an area of the screen or add interest to a user interface.

Graphical User Interface2871PGesture Detection in Android

You want to traverse through different screens using simple gestures like flip/scroll the page.

Graphical User Interface923NSimple Calendar

You desire a simple and native Month view Calendar, which can easily be skinned.

Graphical User Interface1160PBuilding a UI using Fragments API of Android 3.0 in Android 2.2

You want to add Fragments to the UI in Android 2.0+ versions, though they were originally only available in 3.0+. Fragments, as the name suggests, are nothing but the small chunks of UI which constitutes a single activity. It can be treated as individual portlets of a portal page. It is very similar to activity in terms of its looks, lifecycle, etc but it is also different than Activity in the sense that 'A fragment should always reside in an Activity'; fragments cannot exist independently as Activities.

Graphical User Interface1090PAndroid 3.0 Photo Gallery

Display a photo gallery

Graphical User Interface605PCreating a Simple App Widget

Widgets are simple graphical user interfaces that allow users to easily interact with an existing application (activity and/or service). It's rather simple to create one. Just try it!

Graphical User Interface3972NUsing a Compound Drawable

How do I use a "compound drawable", a TextView that contains an ImageView in addition to its text?

Graphical User Interface4012NChange the Text Size for a Spinner

A Spinner is not like a TextView, the textSize attribute will not work (a Spinner is a ViewGroup).

Graphical User Interface4383NAdding a Share Action to your ActionBar

You want to add the standard Share icon to your ActionBar and have it handle an application-provided Intent.

Graphical User Interface4222NChoosing a Layout Manager (ViewGroup)

You want to know how to arrange your GUI components within your view.

Graphical User Interface4188NPrevent flickering when user performs scrolling on a view

How annoying is it when you have created a view only to find screen flicking causes the display to flick vertically before being readjusted

Graphical User Interface4135NCustom Layouts

This is a placeholder recipe for some ideas on layout management aka ViewGroup

Graphical User Interface3823NUsing Existing/Standard Drawables

You want to use existing drawables where possible to give your app a look that is consistent with standard Android.

Graphics1946PIntroduction: Graphics

N/A

Graphics1141PUsing a Custom Font

The range of fonts that comes with Android 2.x is amazingly miniscule - three variants of the "Droid" font. You want something better.

Graphics1529PDraw a spinning cube with OpenGL ES

You want to create a basic OpenGL ES application.

Graphics1425PAdding control to the OpenGL spinning cube

You want to interact with an OpenGL polygon using the keyboard of your device.

Graphics3512PFreehand Drawing Smooth Curves, Signatures, etc.

You want to allow the user to draw smooth curves, such as freehand bezier curves, legal signatures, etc.

Graphics380PTaking a Picture Using an Intent

You want to take a picture from within your app and don't want to write a lot of code.

Graphics1392PTaking a Picture Using android.media.Camera

You want to have more control on the various stages involved when taking a picture.

Graphics3324PScan a Barcode or QR code with Google ZXing Barcode Scanner

You want your App to be able to scan a Barcode or QR Code.

Graphics2289PUsing AndroidPlot to display charts and graphs in your Android application.

Depicting data graphically in an Android application.

Graphics2549PUse Inkscape to Create an Android Launcher Icon

Every good Android App deserves a custom launcher icon.

Graphics2159PEasy Launcher Icons from OpenClipArt.org using Paint.NET

A good icon for an App is important. It helps set an App apart from others and is a must for an App to appear professional.

Graphics3280PUsing Nine Patch Files

When designing a User Interface you want to change the default View backgrounds to fit in with an App's overall style. The backgrounds must be able to scale correctly for different size Views.

Graphics851PAndroid HTML5 RGraph Charting

Need to visualize data in a chart and ability to interaction with the plot/chart via Javascript.

Graphics2749PSimple Raster Animation

There is a need to add an animated image to a screen.

Graphics3230NImageButton State Graphics Using Inkscape

You need to add interest to a screen with custom buttons.

Graphics2273PPinch to zoom

Use the finger touch to change the position of an image viewed on the screen and use pinch-in and pinch-out movements for zooming in and zooming out operations.

Multimedia3151PIntroduction: Multimedia

N/A

Multimedia1383PPlay a Youtube Video

You want to play a video from Youtube on your device

Multimedia1495PUsing Gallery with ImageSwitcher

Creating UI for browse through multiple images.

Multimedia1375PGrabbing a video using MediaRecorder

You want to grab a video using the built-in device camera and save it to disk.

Multimedia1405PAndroid Face Detection

Face detection is a cool and fun hidden api feature of Android, and has been around since Android 1.5. In essence face detection is part of a machine learning technique of recognizing objects using a set of features.

Multimedia1399PPlaying audio from a file

You want to play an audio file stored on the device.

Multimedia1628PPlaying Audio without Interaction

You want to play an audio file with no interaction.

Multimedia1246PUsing Speech to Text

How to get speech input and display it as text

Multimedia1632PMaking the Device Speak with TTS

You want your application to pronounce words of text so the user can perceive them without watching the screens (e.g., when driving).

Multimedia4069NPlaying a Video in your App

You want to play a Video in your application, as opposed to launching a media player application using an Intent (as shown in 1651).

Data Persistence100PIntroduction: Data Persistence

N/A

Data Persistence3220PGetting File Information

You need to know all you can about a given file "on disk", typically on internal memory or on the SD Card.

Data Persistence2452PAccessing data from a file shipped with the App rather than in the filesystem

You need to access data stored in a file in /res/raw directory.

Data Persistence366PListing a Directory

You need to list the filesystem entries named in a directory.

Data Persistence1342PGetting total and free space on the SD card

You want to find out the amount of total and available space on the SD card

Data Persistence3411PEasy User Preferences

You want to let the user specify one or more preferences values, and have them persisted across runs of the program.

Data Persistence561PDefault shared preferences consistency check

Android provides a very easy way to setup default preferences by defining a PreferenceActivity and providing it a resource file. What is not clear is how to perform checks on preferences given by the user

Data Persistence654PAdvanced text search

How to build a data layer to store and search text data using wildcards or expressions like and, or, not, etc.

Data Persistence1919PCreating a SQLite database in an Android application.

Data persistence in the application.

Data Persistence1953PInserting values into a SQLite database.

Adding values into a SQLite database.

Data Persistence1949PRetrieving data from a SQLite database.

Loading items from an existing SQLite database.

Data Persistence413PWork With Dates in SQLite

Android's embedded SQLite3 database supports date and time data directly, including some useful date and time arithmetic. However, getting these dates out of the database is troublesome: there is no Cursor.getDate() in the Android API.

Data Persistence2211PParsing JSON using JSONObject

Many websites provide data in JSON. Many applications require to parse JSON and provide that data in the application.

Data Persistence1656NParsing JSON using the Jackson Parser

Parse JSON using Jackson parser

Data Persistence80PParsing an XML document using the DOM API

You have data in XML, and you want to transform it into something useful in your application.

Data Persistence2217PParsing an XML document using an XmlPullParser

You have data in XML, and you want to transform it into something useful in your application.

Data Persistence3095NSave Data in the cloud with CouchDB and Ektorp

You want to persist data locally and have it backed to a persistence store in the cloud.

Data Persistence334PAdding a Contact

You have some contact information that you want to save for use in the Contacts application.

Data Persistence3115PReading Contact Data

You need to extract details, such as a phone number or email address, from the Contacts database.

Data Persistence3852NAdding Calendar Events

You want to add an event to the user's on-device calendar.

Telephone Applications3137PIntroduction: Telephone Applications

N/A

Telephone Applications1109PDo something when the phone rings

You want to act on an incoming phone call and do something with the incoming number.

Telephone Applications1151PProcess outgoing calls

You want to block certain calls, or alter the phone number about to be called.

Telephone Applications1198PDialing the phone

You want to dial the phone from within an application, without worrying about details of telephony.

Telephone Applications2686PSending single or multipart SMS messages

A simple way to send either a single part or a multipart (handing the message concatenation UDH) from a single entry point

Telephone Applications2017PReceiving an SMS in an Android Application.

Enabling your application to receive an SMS.

Telephone Applications2019PUsing Emulator Controls to send SMS to the Emulator.

For testing SMS based applications sending SMS to the emulator.

Telephone Applications3071PAndroid TelephonyManager.

I want to obtain network related and telephonic information on my phone. How to do this?

Telephone Applications2133NGetting Phone Details.

Some Android applications require the Android device's IMEI number, the phone number or the phone type (GSM/CDMA).

Networked Applications76PIntroduction: Networking

N/A

Networked Applications79PUsing a RESTful Web Service

You need to access a RESTful Web Service.

Networked Applications306PExtracting Information from Unstructured Text using Regular Expressions

You want to get information from another source, but they don't make it available as information, only as a viewable web page.

Networked Applications839PParsing RSS/ATOM feeds parsing with ROME

You want to parse RSS/Atom feeds.

Networked Applications2499NSending an Email using Intents

You need to send an Email through your application

Networked Applications2679NSimple HTTP client functions

How to access services over HTTP fcrom a handset application

Networked Applications2595PUsing MD5 to Digest Free Text

Sometime it is necessary to save or send free text in an encrypted from. Android provides a standard Java MD5 class to allow plaintext to be replaced with an MD5 digest of the original text. This is a one-way digest that is not believed to be easily reversible (if you need that, use Java Cryptography).

Networked Applications2493PConverting text into hyperlinks

You need to make webpage URLs into hyper-links in a TextView of your Android app

Networked Applications2149PAccessing a web page through your Android application

Opening a website within your application.

Networked Applications2373PCustomizing a WebView

You need to customize the WebView opened by your application.

Social Networking102PIntroduction: Social Networking

N/A

Social Networking1313NFacebook Integration

Integrate an Android application with Facebook

Social Networking2213PLoading a user's Twitter timeline (using JSON)

You want to load the Twitter timeline of a user in an Android application.

Social Networking1578PSocial Networking Integration using Http

Instead of diving into the API you can simply add Social networking support.

Location and Map Applications3185PIntroduction: Location-Aware Applications

N/A

Location and Map Applications323PGetting Location Information

You want to know where you are.

Location and Map Applications1703PAccess GPS information anywhere in your application

You need access the GPS location in any class of your application.

Location and Map Applications1229PMocking GPS Coordinates On A Device

You need to demonstrate your application, but are scared it might choke trying to triangulate your GPS coordinates. Or you'd like to simulate being in a place you're not.

Location and Map Applications1454PGeocoding and Reverse Geocoding

How to Geocode and Reverse Geocode on Android

Location and Map Applications4285PGetting Ready for Google Maps API v2 Development

You want to get set up to use the current (V2) Google Maps API.

Location and Map Applications1291PGetting ready for Google Maps API V1 development

You want to get ready to include Google MapView layout elements in your Android app

Location and Map Applications1283NUsing Google Maps in your Android App

Sometimes the steps needed to add a Google Map and show the User's location to Android Apps is not clear as water on the Internet and Documentation.

Location and Map Applications1717NLocation search on Google maps

Doing a location search using Google Maps.

Location and Map Applications1019NHow to show your current location in a map

You want to see where you are in a map using the built-in GPS in Android devices

Location and Map Applications1771PTo Add Device's current location to Google Maps

Adding Current location of the device on Google maps.

Location and Map Applications1541PDraw a location marker on a Google MapView

You have a geo location and you want to display it on a Google MapView view object

Location and Map Applications2338NDraw your current location on a Google MapView

You want to draw your current location on a Google MapView and want to update the location marker on the MapView when the location changes.

Location and Map Applications2308PDrawing multiple location markers on a MapView

You have several GeoPoints which you want to display on a Google MapView.

Location and Map Applications1752PCreating Overlays for a Google MapView

Demarcating a point on a Google map using an image.

Location and Map Applications2287PChanging Views of a MapView.

Showing an appropriate view of a MapView based on the context in the application.

Location and Map Applications1354PDraw overlay icon without using Drawable

How can you display an map overlay in MapView without using Drawable objects?

Location and Map Applications897PMapView inside TabView

You want to place a MapView object within TabView.

Target application outline

  • Draw two empty tabs
  • Show map on the first tab

Location and Map Applications462PHandling longpress in a map

For some map applications you might want to let the user trigger an action related to an arbitrary point on the map, for example through a context menu. Enabling the user to do a longpress on the map is among the more intuitive ways to expose this kind of functionality, but support for this is not built in to Android. Let me show you how you can add it yourself.

Location and Map Applications2521PUsing OpenStreetMap

You want to use OpenStreetMap (OSM) map data in your application in place of the standard Google Maps.

Location and Map Applications2618PCreating overlays in OpenStreetMaps

You need to create overlays for your OpenStreetMap

Location and Map Applications2654PUsing a scale on an OpenStreetMap

You need to show a map scale on your OSM to indicate the level of zoom on the MapView

Location and Map Applications2625PHandling touch events on an OpenStreetMap Overlay

You need to perform actions when the overlay on an OpenStreetMap is tapped

Location and Map Applications2658PGetting location updates with OpenStreetMaps

You need to react to the changes in the device's location and move the map focus to changed location

Location and Map Applications4297PUsing the Google Maps API V2

Now that you've set up your environment as in 4285, you want to do something with the Maps API.

Accelerometer and other Sensors2056PIntroduction: Sensors

N/A

Accelerometer and other Sensors2047PChecking for the Presence or Absence of a Sensor

Before using an Android device for a sensor-based application, the programmer needs to ensure that the required sensor is supported by the device.

Accelerometer and other Sensors529PUsing the accelerometer to detect shaking of the device

Sometimes it makes sense to evaluate not only on-screen input, but also gestures like tilting or shaking the telephone. But how can you use the accelerometer to detect whether the phone has been shaken?

Accelerometer and other Sensors2051PChecking for device facing up or facing down based on screen orientation using Accelerometer.

Check for the orientation (Facing up/Facing Down) of the Android device.

Accelerometer and other Sensors2085PFinding the orientation of an Android device using Orientation sensor.

Being able to detect which side of the android device is higher up compared to the rest (Top/Bottom/Right/Left side)

Accelerometer and other Sensors2385PReading the Temperature Sensor

You need to get temperature values using the temperature sensor.

Bluetooth3159PIntroduction: Bluetooth

N/A

Bluetooth1978PEnabling Bluetooth and making the device Discoverable.

If the application requires the Bluetooth adapter to be switched On, the programmer needs to check if its enabled. If it is not, the use should be prompted to enable Bluetooth. For allowing remote devices to detect the host device, the host device should be made discoverable.

Bluetooth1665PConnecting to Bluetooth enabled device

You need to connect to other bluetooth enabled device and want to communicate with it.

Bluetooth1991PListening for Bluetooth Connection Requests.

Creating a listening server for Bluetooth Connections.

Bluetooth1615PBluetooth Device discovery

You want to display a list of Bluetooth devices in the vicinity.

Other Programming Languages1036PIntroduction: Other Programming Languages

N/A

Other Programming Languages1365PRun external/native Linux command

Sometimes it can be convenient to start one of the Linux commands that are available on the phone such as rm, sync, top, uptime...

Other Programming Languages77PRunning Native Code with JNI on the NDK

You need to run parts of your application natively in order to use existing C/C++ code or, possibly, to improve performance of CPU-intensive code

Other Programming Languages1034PGetting Started with ''Scripting Layer for Android'' (formerly Android Scripting Environment)

You want to write your application in one of several popular scripting languages, or, you want to program interactively on your phone.

Other Programming Languages2426NInstalling and Using Android Scripting Environment (ASE)

You need to run scripts (python, perl, lua etc) on an Android device.

Other Programming Languages2885PCreating alerts in SL4A

You need to create an alert box or pop-up dialog using Python in the Scripting Layer for Android (SL4A)

Other Programming Languages2907NCreating notifications in ASE

You need to create a notification using python in Android Scripting Environment

Other Programming Languages2834PGet your Google Documents and show them in a list view using SL4A

You need to get the details of your Google documents after logging in with your Google ID and password.

Other Programming Languages2505NMaking a Toast in Python (Using Android Scripting Environment)

You need to make a Toast using python (Using ASE)

Other Programming Languages2916PSharing your scripts (ASE) using QR codes

You need to distribute your ASE scripts using QR (Quick Response) Codes

Other Programming Languages1046NRunning Adobe Air/Flex on Android

Developing AIR/Flex Apps for Android.

Other Programming Languages2074NIntro to Flex 4.5 Android Programming

Creating an Android-application using Flex 4.5. The application uses a company stock symbol as query, and an HTTP service to Google's Finance API, retrieving stock data.

Other Programming Languages2369PUsing native handset functionality from webview using Javascript

The advent of HTML5 as standard in many browsers means that applications can exploit the features of the HTML5 standard to create applications much more quickly than if they were written in native Java. This sounds great for many applications but alas not all of the cool functionality on the device is accessible through HTML5 and Javascript. Webkits attempt to bridge the gap but may not provide all the functionality needed in all cases.

Other Programming Languages3542PPlatform Independent Application Using PhoneGap/Cordova

You want an application to run on different platforms like iOS, Android, BlackBerry, Bada, Symbian, Windows etc.

Other Programming Languages3549NPhoneGap (Android) Using JQuery Mobile

You need to use JQuery mobile in your Mobile App (since it is platform independent).

Other Programming Languages3547NPhoneGap (Android) Accessing your java files from javascript

You need to access your methods from Activity.java in JavaScript

Other Programming Languages3224NEasy Apps with App Inventor (placeholder recipe)

You want to generate Android applications without needing to write either Java code or HTML.

Strings and Internationalization350PIntroduction: Internationalization

N/A

Strings and Internationalization358PInternationalizing Application Text

You want the text of your buttons, labels and so on to appear in the user's chosen language.

Strings and Internationalization2874PFinding and Translating Strings

You need to find all the strings in your application, internationalize them, and begin the process of translating them.

Strings and Internationalization2219PThe Nuances of strings.xml

Entering text in strings.xml on most occasions is easy enough, but sometimes peculiar results crop up.

Packaging, deploying and selling502PIntroduction: Packaging, Deploying and Distributing

N/A

Packaging, deploying and selling660PCreating a Signing Certificate

You want to publish an application, and you need a "signing key" to complete the process.

Packaging, deploying and selling662PSigning Your Application

You want to sign your application prior to uploading it to the Android Market.

Packaging, deploying and selling600PDistributing Your Application via the Android Market

You want to give away or sell your application via the Android Market.

Packaging, deploying and selling724PHow to integrate Admob into your app

You want to monetize your free app by showing ads within it.

Packaging, deploying and selling2111PObfuscating and Optimizing with ProGuard

You want to obfuscate your code, or optimize it (for speed or size), or all of the above.

Packaging, deploying and selling3172PProvide a Link to other Published Apps in the Market

Your developed App is running on a device; you want a link to your other Apps on the Android Market to encourage users to try them.

Packaging, deploying and selling3156NBuilding your App as an Open Source Project

You want to build your Android App as an open source project, building it collaboratively with a vibrant community of developers.

Packaging, deploying and selling3562NMerging two different applications in one application.

If you have two different application say one is application and one is service layer then how to send them in one apk?

Packaging, deploying and selling3961NRunning Android Apps on the BlackBerry Playbook

Your App works fine on real Android devices, and you're ready to move it to the next easy target: the Reserch In Motion (RIM) BlackBerry Android Player.

Packaging, deploying and selling4124NAlternate Home Screen (Kiosk Mode Phone)

You need to provide an alternate home screen for your phone.

Packaging, deploying and selling3794NPassing Android Code Around

There are plenty of code samples around, this site included, a clean way to use (and generate) example code is needed.

GUI: ListView1882PIntroduction: ListView

N/A

GUI: ListView397PBuilding list-based applications with ListView

Many mobile applications follow a similar pattern, allowing users to browse and interact with multiple items in a list. How can developers use standard Android UI classes to quickly build an app that works the way users will expect, providing them a list-based view onto their data.

GUI: ListView3384NAdd a Selection List using ListActivity

Your App needs the user to select an item from several options.

GUI: ListView1865P'No data' View for Lists

When the ListView has no items to show, the screen would just appear blank. In order to show an appropriate message on the screen, indicating the absence of data in the list.

GUI: ListView1418PAdvanced ListView: populating a list with images and text

You want to write a ListView that shows an image next to a string.

GUI: ListView830NListView with Icons/images

You want to display data in a ListView with an icon image and some text for each ListView row.

GUI: ListView992PSectioned Headers in ListViews

You want to display categorized items e.g., by time/day, by product category or sales price.

GUI: ListView1761NMaking Lists Behave Nicely

Lists are easy to get started with, but there are a lot of variations that will provide optimal user experience.

GUI: ListView588PWriting A Custom List Adapter

Lists are ubiquitous throughout mobile applications. Android provides a simple and powerful interface to make exactly the list you need. This recipe explains the steps for customizing the content of a ListView.

GUI: ListView3759PKeeping the ListView with the User's Focus

You don't want to distract the user by moving the ListView to its beginning, away from what the user just did.

GUI: ListView862POrientation Changes : From ListView data values to Landscape Charting

Accomplish view changes on device orientation changes. For example, data values to be plotted are contained in a Portrait ListView, and upon device orientation a graphical display of the data values in a chart/plot is displayed.

Gaming and Animation1816PIntroduction: Gaming and Animation

N/A

Gaming and Animation2030PGame Programming with Flixel-Android

Game design

Gaming and Animation2034PGame Programming using AndEngine (Android-Engine)

Game design and programming using the AndEngine game framework

Gaming and Animation3345PProcessing timed keyboard input

To determine if a user generated message, like a key press/release, has occoured within a certain time interval. Useful in game input handling.

System and Device Control104PIntroduction: System and Device Control

N/A

System and Device Control1351PPhone network/connectivity information

You want to find information about phones network connectivity

System and Device Control2326PReading information from Manifest file

You want to read project settings (e.b, app version) data from the AndroidManifest file during program execution.

System and Device Control2584PChanging incoming call notification to Silent, Vibrate, or normal

You need to put the Android device to silent, vibrate or normal mode

System and Device Control2544PCopying text and getting text from the Clipboard

You need to copy text to the clipboard and access the text stored on the clipboard

System and Device Control2301PMaking LED based notifications

Some Android phones are equipped with LEDs. An application can flash different color lights using the LED.

System and Device Control2092PMaking the Device Vibrate.

Through your application, you wish to notify the user of an event by means of device's vibration.

System and Device Control2457PRunning shell commands from your application

You need to run a shell command from your application (for instance pwd, ls etc).

System and Device Control2467PDetermining Whether a Given Application is Running

How do i know if mine or some other app is running?

System and Device Control2077NRebooting the Device

For some strange reason, you want the user's Android device to reboot.

System and Device Control2404NRebooting the Device - The Hack Way

If you want to reboot an emulator, the hack way!

Inter/Intra-Application Communication73PIntroduction: Inter-Communication

N/A

Inter/Intra-Application Communication1651POpening a Web Page, Phone Number or anything else with an Intent

The Intent mechanism is fundamental to Android; it allows one application to have some entity processed by another application without knowing or caring what that application is.

Inter/Intra-Application Communication870PEmail Text From a View

You want to send an Email containing text or images from a View. The data to be emailed is passed as a parameter using an Intent.

Inter/Intra-Application Communication1441PSending an email with attachments

You want to send an e-mail with attachments.

Inter/Intra-Application Communication809PHow to push string-values using Intent.putExtra()

You need to pass some parameters into an activity while launching it.

Inter/Intra-Application Communication899PRetrieving data from a Sub-Activity back to your Main Activity

Your main activity needs to retrieve data from a sub activity.

Inter/Intra-Application Communication844PKeeping a Service running while other apps are on display

You want part of your application to continue running in the background while the user switches to interact with other apps.

Inter/Intra-Application Communication934PSending/Receive broadcast message

You want to make an activity which receives a simple broadcast messages sent by another activity

Inter/Intra-Application Communication1713NIntercommunication amongst Applications

You need to get different applications deployed on a device to communicate. For instance, the running application wishes to notify another application (which is in the background) of a certain event.

Inter/Intra-Application Communication1662PStarting a service after phone reboot

You have a service in your app and you want it to start after the phone reboots.

Inter/Intra-Application Communication1370PCreating a Responsive Application using Threads

How to create a responsive application.

Inter/Intra-Application Communication1961NEating Too Much CPU Time In The UI Causes A Nasty Result

Any time consuming or intensive code in an event listener will make the UI appear slow and potentially cause an Application Not Responding error.

Inter/Intra-Application Communication1433NAsyncTask: Do background tasks and modify the GUI

If you run a thread to execute some source code, you can't use or change any graphical widget from this thread and you don't know when the thread has finished.

Inter/Intra-Application Communication2260PUsing AsyncTask to do background processing

You have to do some heavy processing, or load resources from the network and want to show the progress and results in the UI.

Inter/Intra-Application Communication921PSending messages between threads using activity thread queue and Handler class

You need to pass information or data from a Service or other background task, to an Activity. Since Activities run on the UI thread it is not safe to call them from a background thread.

Inter/Intra-Application Communication877PJava to JavaScript: Android Epoch HTML/Javascript Calendar

You require a custom calendar using Javascript. This recipe also shows how to interact between Javascript and Java.

Inter/Intra-Application Communication4426NExchanging Array Data between Java and JavaScript

You want to push array data from Java to JavaScript and/or from JavaScript to Java

GUI Alerts: Menus, Dialogs, Toasts and Notifications3734PIntroduction: GUI Alerts

N/A

GUI Alerts: Menus, Dialogs, Toasts and Notifications1891PCreate and Display a Menu

Within the Activity, showing a menu on pressing the Menu button of the Android device.

GUI Alerts: Menus, Dialogs, Toasts and Notifications1896PHandling Choice Selection in a Menu.

After Creating a custom menu, implementing a reaction on clicking the menu item.

GUI Alerts: Menus, Dialogs, Toasts and Notifications2089PCreating a Submenu.

Display options to the user in an floating window.

GUI Alerts: Menus, Dialogs, Toasts and Notifications1885PCreating and Using Dialogs

You need to prompt the user of some event or state which requires immediate confirmation or a choice. For example, if the user tries to move away from a page with unsaved changes and you don't want to sae them automatically, you might prompt the user for what to do.

GUI Alerts: Menus, Dialogs, Toasts and Notifications1925PUse a Timepicker widget

Sometimes we need to ask the user to enter the time for processing some element in the application. Accepting time in Text boxes is not graceful as well as requires validation.

GUI Alerts: Menus, Dialogs, Toasts and Notifications883PiPhone-like wheel picker for selection

Want a selection UI component similar to iPhone wheel picker.

GUI Alerts: Menus, Dialogs, Toasts and Notifications1746PCreating a Tabbed Dialog

Categorizing information display in an custom Dialog.

GUI Alerts: Menus, Dialogs, Toasts and Notifications2254PCreating a ProgressDialog in Android.

Making the user aware of background processing happening in the application.

GUI Alerts: Menus, Dialogs, Toasts and Notifications1728PCreating a Custom Dialog with buttons, images and text

Using a custom dialog in the application. The dialog is provided with text, images, buttons and also providing tabs in the dialog.

GUI Alerts: Menus, Dialogs, Toasts and Notifications3448PA Re-usable About Box Class

About Boxes are common in any application it is useful not to have to recode them for each new App.

GUI Alerts: Menus, Dialogs, Toasts and Notifications2334PCustomizing the Look of a Toast

You want to customize the look of Toast notifications.

GUI Alerts: Menus, Dialogs, Toasts and Notifications795PCreating a Notification in the Status Bar

You want to place a notification icon in the notice bar at the top of the screen, to call the user's attention to an event that occurred or to remind them of a service that is running in the background.

GUI Alerts: Menus, Dialogs, Toasts and Notifications4254PUsing ActionBar on older Devices

The ActionBar component, introduced in Honeycomb and upgraded in ICS, is a combination of a titlebar, menu items that get promoted to buttons, and a Menu Button to replace the hardware button that is absent in almost all 3.0+ devices. This is good functionality, and it would be nice to be able to use it on pre-4.x devices.

Other (temporary holder)3947NIntroduction: "Other" Category

N/A