AppThwack – Automated testing of iOS and Android apps on real devices in the cloud

AppThwack maintains a remote device lab of hundreds of iOS and Android devices and an automation infrastructure that allows you to run automated test scripts in parallel on real devices, not emulators. AppThwack supports all popular automation frameworks. With AppThwack, you can

  • Execute your tests, in parallel, across 100s of iOS and Android phones and tablets with results available in minutes
  • Initiate tests through a simple web interface or Jenkins Plug-in
  • View results in web-based dashboard or download for offline viewing
  • Analyze reports in real-time that include high-level results, low-level logs, pixel-perfect screenshots, and performance trends (CPU, Memory, Threads, Frame draw time)
  • Integrate report data with CI and other business flow applications

AppThwack offers a free 7-day trial period. Start testing with AppThwack today!

Remote debugging on Chrome for Android

A couple of new features in DevTools make remote debugging on Chrome for Android easier to setup: the ADB extension and reverse port forwarding.

The ADB Chrome extension simplifies the process of setting up remote debugging. It provides the following benefits:

  • Bundles Android Debug Bridge (ADB) so you don’t have to install it.
  • No command line interaction required.
  • UI for easily starting and stopping the ADB daemon, and viewing connected devices.

Reverse port forwarding makes it easy to connect Chrome on Android to a web server running on your localhost, something that some network environments make difficult without some DNS tricks.

Using the ADB extension

First, install the ADB Chrome extension from the Chrome Web Store. Click Add to Chrome to install the extension.

Installing extensions from the Chrome Web Store isn’t supported on Windows 8. If you have any problems installing from the Chrome Web Store, seeRemote Debugging on Android for alternate installation instructions.

Once installed, a gray Android menu icon appears in Chrome. To start ADB, click the icon and then click Start ADB.

ADB extension menu

Once ADB has started, the menu icon turns green and displays the number of currently connected devices, if any.

ADB extension menu showing connected devices

Click View Devices to open the about:inspect page that displays each connected device and its tabs. To inspect a tab in DevTools, click the “inspect” link next to its URL.

about:inspect page showing links for device tabs

If you don’t see any connected devices, check that your device is connected to USB, and that USB debugging is enabled in the Chrome for Android settings. For more detailed instructions and troubleshooting steps, see Remote Debugging on Android.

Reverse port forwarding (experimental)

Commonly you have a web server running on your local development machine, and you want to connect to that site from your device. If the development machine and the device are on the same network, this is straightforward. But in some cases, like on restricted corporate networks, this may not be possible without some clever DNS tricks. A new feature in Chrome for Android called reverse port forwardingmakes this simple to do. It works by creating a listening TCP port on your device that forwards traffic over USB to a particular TCP port on your development machine.

To use this feature you will need:

  • Chrome 28 or later installed on your development machine
  • Chrome for Android Beta installed on your device
  • Android Debug Bridge (ADB Chrome extension or full Android SDK) installed on your development machine

To use reverse port forwarding, you need to have your device connected for remote debugging, as described in Using the ADB extension. Then you need to enable reverse port forwarding and add a port forwarding rule for your application.

First, enable reverse port forwarding:

  1. Open Chrome on your development machine.
  2. In about:flags, turn on Enable Developer Tools experiments and restart Chrome.
  3. Open about:inspect. You should see your mobile device and a list of its open tabs.
  4. Click the “inspect” link next to any of the sites listed.
  5. In the DevTools window that opens, open the Settings panel.
  6. Under Experiments, turn on Enable reverse port forwarding.
  7. Close the DevTools window and return to about:inspect.

Then add a port forwarding rule:

  1. Click the “inspect” link again to open DevTools, and open DevTools Settings again.
  2. Click the Port Forwarding tab.
  3. In the Device port field, enter the port number Chrome should connect to on your Android device (defaults to 8080).
  4. In the Target field, append the port number where your web application is running on your development machine.

    Port forwarding tab in DevTools Settings

  5. In Chrome for Android, open localhost:<device-port-number>, where <device-port-number> is the value you entered in the Device portfield (default is 8080).

You should see the content being served by your development machine.

Create cross-platform apps with PhoneGap and jQuery Mobile

One of the biggest challenges of developing mobile applications is trying to port the application to multiple platforms. This can lead to extensive development costs, and the need for multiple skillsets internally in order to maintain the application. This has led to the development of a number of technologies that provide a cross-platform solution.

Arguably, the most popular of these technologies is PhoneGap. The solution allows developers to create applications with a familiar tool set: HTML, CSS, and JavaScript.


 When PhoneGap is combined with a mobile web development framework, it’s possible to develop cross-platform mobile applications quickly. One of the most popular frameworks is jQuery Mobile due to its simplicity and native look and feel.

I’ll demonstrate how to develop a simple application that uses PhoneGap APIs with jQuery Mobile to search for a list of contacts by name and display them (Figure A). Then, I’ll show how to deploy the application to your Android device with PhoneGap.  Follow along with the step-by-step tutorial, or download and import the project.

Figure A


1. Install PhoneGap. It’s platform dependent, so I refer you to the PhoneGap documentation.

2. Execute the following lines in a terminal window to create the application in the current directory:

$ phonegap create ContactsList
$ cd ContactsList
$ phonegap run android

3. PhoneGap provides a variety of plugins for accessing the native APIs of a device.  This example will make use of the PhoneGap Contacts Plugin. To add the Contacts Plugin, execute the following at the command line:

$ phonegap local plugin add

4. Enable the plugin within your PhoneGap application by adding this line to the app/res/xml/config.xml file:

<plugin name="Contacts" value="org.apache.cordova.ContactManager" />

5. You must provide permissions to contacts within the AndroidManifest.xml, so within the application, add these lines to the app/AndroidManifest.xml file:

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />

6. Now you’re ready to start developing the application. The first step is to create a page that will hold the list of contacts you’re attempting to show. With jQuery Mobile, this is achieved using the <div data-role=”page”> element. Copy this code snippet into the www/index.html file of your application:

<!DOCTYPE html> 
	<title>Page Title</title> 

	<meta name="viewport" content="width=device-width, initial-scale=1"> 

  <link rel="stylesheet" 
    href="" />
  <script type="text/javascript" src="phonegap.js"></script>
  <script src=""></script>
  <script type="text/javascript" src="js/index.js"></script>
  <div data-role="page">
    <div data-role="header">
      <h1>Show My Contacts</h1>
    </div><!-- /header -->

    <div data-role="content">	
      <div id="contactsList">
    </div><!-- /content -->
  </div><!-- /page -->


We included the jQuery Mobile script and stylesheet in the <head>; this is all that is needed to use the jQuery Mobile framework. Within the <div data-role=”page”> element, we define the <div data-role=”header”> and <div data-role=”content”> elements. These elements define what content will be rendered in the page header and the content section, respectively.

7. In the previous snippet, there was an empty <div id=”contactsList”>; this <div> element will contain your contacts list. You can use JavaScript to retrieve the contacts and display them. PhoneGap provides an event to hook into the moment the application is loaded, and the device is ready. Replace the code in the www/js/index.js file with the following:


document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    // find all contacts with 'Jacob' in any name field
    var options = new ContactFindOptions();
    options.filter = "Jacob";
    options.multiple = true; 
    var fields = ["displayName", "name", "phoneNumbers"];
    navigator.contacts.find(fields, onSuccess, onError, options);

This code snippet adds a listener that will retrieve all contacts with “Jacob” anywhere in the name once the device is ready. The data returned from the retrieval will contain the contact names and phone numbers, and will be passed to an onSuccess method.

8. After retrieving the contacts, you need to display them to the user. You can use the jQuery Mobile Collapsible List to display the contact names and allow them to be expanded to show the phone numbers. Add the following snippet to the www/js/index.js file:


function onSuccess(contacts) {
  for(var i = 0; i < contacts.length; i++) {
    var html = '<div data-role="collapsible" data-inset="false">';

    html += '<h2>' + contacts[i].displayName + '</h2>';
    html += '<ul data-role="listview">'

    var contact = contacts[i];

    for(var j = 0; j < contact.phoneNumbers.length; j++) {
      html += '<li>' + contact.phoneNumbers[j].type + 
        ": " + contact.phoneNumbers[j].value + '</li>';

    html += '</ul></div>';



function onError(contactError) {

Notice that we make use of the PhoneGap Contact object here. Be sure to specify the fields you want to use when finding the contacts list.9. If you have your Android device or an emulator set up appropriately, execute this command to deploy the application:


$ phonegap install android

Keep exploring

Try deploying the application to other platforms and using additional PhoneGap APIs. It may just convince you to use the platform for your next app.

Installing the Best Android Dev Environment: Intellij IDEA and Genymotion Emulator

Every few months, I check out new build tools. When I first began building Android apps, I used Google’s Android Toolkit, Eclipse and Google’s Emulators. Pretty quickly, I grew impatient with Google excruciatingly slow emulator and switch to always deploy to my device.

Then I started using VirtualBox based emulators, switched from Eclipse to Intellij IDEA, and finally switched to using Genymotion’s emulator. So here are the steps necessary to set up your Mac and the links to where to find everything.

I will be posting a video of these instructions to YouTube in about a week. I have a lot of editing to do to take about three hours of video to about 10 minutes.

Installing the complete Android development kit is going to take about two hours, possibly more. I highly recommend that you do it all in one sitting, to avoid accidentally re-installing an installed component or even worse not installing a component. We are going to need five components:

  1. Oracle’s Java Development Kit (JDK)
  2. Android Developer’s Toolkit (ADT)
  3. JetBrains’ Intellij IDEA Community Edition
  4. Oracle’s VirtualBox
  5. Genymotion Android Emulator


There is a bit of disagreement about which version of the JDK to use for Android development. The current version of Java, at the time of writing, is JDK 7. JDK 8 is currently in beta. But the Android developer’s official page list JDK 6 as the version to use. Until the developer’s page changes, I am going to recommend that we use JDK 6. Here is the link to that version on Apple’s developer website. You will need to be registered as a developer in order to access this page.

In Categories, clear everything except Developer Tools and use “java” as the search term. Don’t use JDK 7 or 8. I have never been able to get them to work correctly. If you do so, you will have to clean up your dev box on your own. Select the version labeled, “Java for OS X 2013-005 Developer Package”. Be sure that this is your version. There are others with really close names, but close is not good enough. Click the disclosure arrow to expand it. Click the Java Developer Package… link on the right hand side to download the .dmg file. Once it has finished downloading, double click the .dmg file to open it, then double click the JavaDeveloper.pkg file to start the install.

To validate the installation we need to use the Terminal. Open a Terminal window and type:

javac -version

It should respond with: javac 1.6.0_65. If it does you are good to go. If it doesn’t STOP, don’t go any further we need to fix it before we do anything else.


There are two issue that I am aware of that can cause issues. There are probably more but I haven’t encounter them yet, so I can’t help you with them.Issue number one: You have another version of Java installedIf the response is: javac 1.7.0_45 or some other version number, you have another version of the JDK installed. First thing we need to do is verify that you have version 6 installed. From the terminal type:cd /Library/Java/JavaVirtualMachines returnls returnThe ls command is the roughly the same as the dir command on a Windows machine. We should see 1.6.0_65-b14-462.jdk listed. If so, we just need to add a JAVA_HOME to our profile. If we don’t see 1.6.0_65-b14-462.jdk listed, we didn’t install it correctly. I suggest trying the install again.Issue number two: We need to add JAVA_HOMEJAVA_HOME informs all tools looking for the JDK where it lives. To add we once again need to go to Terminal. From the command line enter:vim ~/.bash_profilevim is a text editor from the dawn of time. It has a funky UI, which is a bit hard to grok, but luckily all we need to do is add one line and save it. Enter the following line:export JAVA_HOME=”/Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home/”Then press escape XX, which is the escape key followed by shift X shift X. This will save our change and exit vim. Our profile should now point JAVA_HOME to our newly installed JDK 6. At this point I usually restart my machine to make sure all of my change get picked up, but I have been told all you need to do is log out then back in again.


Since we don’t want to use Eclipse, all we need to download is the Android Developer Tools, not the ADT Bundle. Just the ADT. 

In your browser go to:
Scroll down to the bottom of the page.Click the expando, “USE AN EXISTING IDE”Click the button, Download the SDK Tools for MacThe folder, “android-sdk-macosx, will download load to your machine, I recommend copying it to your application folder since most of the contents in it are executables. Once you have copied the folder to your applications folder you will need to run the app “android” in order to install SDK and other tools that you need. You will need to override OS X’s security setting in order to run the android app. Find it using the finder, then hold down the control key while double clicking the app name. A security warning will pop up. Don’t freak out. This is to be expected. Confirm that you want to run the android app. In a couple of seconds, the Android SDK installer program will appear.For now only install Android SDK 19, or whatever the latest version is. Each version is kind of big and we don’t want to spend all day installing SDKs we don’t need. Besides it is pretty easy to add more SDKs later.

Intellij IDEA

We are finally ready to install the actual IDE. Use your browser to go to:

Click the button to download the Community Edition. It will take a few minutes to download the .dmg file.Launch Intellij in order to finish the installation. Once the Welcome menu shows:Double click Create New ProjectSelect Application Module from the Android section on the left sideWe need to configure both the JDK 6 and our Android SDKClick the New… button in the upper right hand cornerFirst we will configure the JDKIn the file finder dialog box navigate to:/Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/HomeClick ChooseClick the New… button again. Now lets find our android SDK folder.In the file finder dialog box navigate to:  /Applications/android-sdk-macosxClick Choose


VirtualBox is a free virtual machine app. It is required by the Genymotion emulator.Go to:
Click the link: VirtualBox 4.3.8 for OS X hosts -> x86/amd64Double click the dmg file and follow instructions.


Genymotion is a virtual machine based emulator for Android. It not a Google product. It is unbelievably fast. It is fast enough to play arcade games on it. They have a wide variety of devices in the emulator library. My normal workflow is to build and test on emulators and once I am confident I will test on actual hardware. Their emulators are also nice when demo an app on a projector.

It is free for private use. You must be registered in order to download emulators.Go to: register. They will send a link to your email address in order to confirm it. Click the link and you are in.Download the emulator from the download pageDouble click the dmg fileDrag the Genymotion app to the application folderDrag the app to the application folderDouble click the Genymotion app in your application folder to launch itClick the Add button to download an emulated deviceI would recommend initially downloading a Nexus 4 (phone). You should now be able to build and deploy an Android app to the Genymotion device.

AMFConnection for AMF remoting in Java

In couple posts back, I talked about using NetConnection to talk to a remoting destination in BlazeDS/LCDS. This helps for pure Flash clients talk to BlazeDS/LCDS but what if you have a Java client app and you want to do a remoting call from your Java app, is this possible? That’s when AMFConnection comes into play.

I created this nice little class in BlazeDS source tree a while back. It tries to mimic Flash’s NetConnection in Java (hence the name AMFConnection) and inspired by Peter Farland‘s AMFConnection. It uses BlazeDS’ AMF serializer/deserializer (which means you need flex-messaging-common.jar and flex-messaging-core.jar from BlazeDS in your classpath) and it can potentially be used from any Java code to serialize/deserialize AMF messages. Internally, Java’s HttpURLConnection is used to send/receive HTTP request/replies and can be used to perform remoting calls to BlazeDS, LCDS, or any other server technology that understands AMF from your Java client.

You would use AMFConnection pretty much like NetConnection. One notable difference is that calls are not asynchronous which makes sense for Java. Here’s a brief example:

// Create the AMF connection.
AMFConnection amfConnection = new AMFConnection();

// Connect to the remote url.

// Make a remoting call and retrieve the result.
Object result =“remoting_AMF.echo”, “Hello World!”);
catch (ClientStatusException cse)
// Handle exception.
catch (ServerStatusException sse)
// Handle exception.

// Close the connection.

A full example can be found in this JUnit test in BlazeDS source tree.

How to Get Any File to Play Back on Your Android Phone

Android may be a versatile OS, but the little green robot can run into trouble when it comes to certain file formats. RAW photo formats such as .NEF won’t show up in the default Android’s image and video Gallery app. Even common video file formats such as .AVI and .MKV will stop most Android phones in their tracks.

Luckily, there are apps and workarounds so your Android phone can open most audio, video, image, and Office file formats you throw at it. Being able to playback a myriad of file formats is good because not all file formats are created equal. RAW images, for example, tend to be of higher quality than standard .JPEGs. And .MKV files can play videos with subtitles–helpful if you are hard of hearing, watching a foreign film, or stuck on an airplane with crummy headphones.

Also, by making your phone accept a more diverse number of file formats, you can save yourself the hassle in converting your media files into (more often than not) inferior and more common file types that aren’t as good at reproducing hi-fidelity music, saving storage space, and displaying crystal clear images.



The default Android media player is very picky about what it accepts if you try to load it with anything other than .MP3s. For a better audio experience, look no further than the PowerAmp Music Player. The list of formats that PowerAmp can play includes .MP3 (of course), .MP4, .M4A, .ALAC, .OGG, .WMA, .FLAC, .WAV, .APE, .WV, and .TTA. Besides accepting a wide variety of audio formats, PowerAmp is customizable with several themes and comes with a handful of widgets to choose from. PowerAmp costs $5 for the full version, though there is a free 15-day trial as well so you can try it out before you buy.

Mortplayer Music

If you don’t feel like spending $5 on an app, you can also try out Mortplayer Music. Mortplayer (free) can handle all the same formats that PowerAmp can, though the interface is not as clean as the one in PowerAmp and it cannot play .FLAC files on all devices.

Office Documents

While Windows Phone 7 phones may be the kings in handling Office documents, Android also can juggle work documents (Word, Excel, PowerPoint, and Adobe) with ease. All Android devices by default can view Office documents, but you will need a separate app in order to edit and create new ones. There are quite a few mobile office apps to choose from; it really boils down to what features you want.

Google Docs

I personally prefer to use QuickOffice ($15) because it can sync my files with my DropBox or Google Docs accounts. Chances are your phone came pre-loaded with the trial version of a mobile office app. Much like with PowerAmp, I would recommend playing around with a trial version before committing $15 for an app that doesn’t have the features you want.

One workaround is Google Docs, Google’s online service for creating and viewing office documents. The official Docs app does a sufficient job at displaying your documents. However the app has issues with keeping document formatting, so I would not recommend using it to create or edit your work. Results may vary on your Android phone or device. For all other text formats, the best and easiest workaround would be to e-mail the document to your Gmail account, then view the document using the “Preview” option inside your Gmail message. You may not be able to work on it, but at least you can read what the file says.



By default, the Android Gallery can handle most standard image formats (.JPEG, .GIF, .PNG, and .BMP). Unfortunately after searching the Android Market, I only found one app that allows you to view images in the RAW format. The app is called RawDroid(free) and is currently only available as a demo, though it allows you to view images in formats such as .NEF and .CR2.

For Adobe Photoshop users who live and breathe by .PSD files, as of now, there is no apps solution for viewing that file format. Even Adobe’s own Photoshop Express application wouldn’t recognize the ones I loaded onto my phone’s SD card. Hopefully Adobe’s Photoshop app is updated and .PSD formats are supported in the future.

How to remotely install apps on your smartphone

You can download and install apps to your iPhone and Android phone without being anywhere near it. That sorcery is this? It isn’t sorcery. It’s the internet. And it takes almost no effort to set up.

On Android

If you have an Android phone, you can quickly and easily remotely install apps to your phone without having to tinker with any settings. Visit the Google Play store from your computer and log in using the Google account that’s associated with your phone. Next, find the app that you want to install and go to its information page, then press the Install button for that app.

Select the device you want to install the app on, then press Install.

Once you click Install, you’ll be presented with a box that tells you which permissions the app needs (whether it needs to access your contacts or connect to the Internet, for instance), as well as a drop-down list of the devices associated with your Google account. Select the phone or tablet you want to install the app on from this list, then press Install. After a few moments, your phone will begin installing the app.

Pretty easy, right? You betcha.

On iOS

Toggle this switch…

iOS 7 comes with a similar feature, but you need to make sure it’s switched on first. To check, open the Settings app, scroll down, then tap iTunes & App Store. From here, look for the Automatic Downloads section, then toggle the Apps slider to the on position (the toggle switch will turn green). If you want to have updates downloaded to your phone automatically, switch the Updates toggle to the on position as well.

…then download your app. It will appear on your iPhone’s homescreen a few moments after you purchase it on your computer.

Next, open iTunes on your Mac or PC, then go to the iTunes Store, and sign in using the Apple ID associated with your phone. Go to the App Store, then find an app you want to download. Press the Download buttom—it will be labelled with the app’s price—and after a few moments it will be downloaded to both your computer and your phone.

On Windows Phone 8

Setting up your Windows phone for remote app installation is similar to the process for iOS. Start by going to the Settings app on your phone and then select Find My Phone from the list. Next, look for the checkbox labelled Send apps to my phone using push notifications (not SMS) and tap it if it isn’t checked already.

Now go to the Windows Phone store, then mouse over Explore My Phone in the upper-right corner and sign in with the Microsoft account associated with your phone. Find the app you want to install, and press the Buy or Install button (which button label you see will depend on whether the the app is paid or free).

Once you do that, the Windows Phone store will pick your default device and install that app to it after a few moments.

Four Ways To Build A Mobile Application, Part 2: Native Android

This article is the second in a series of four articles covering four ways to develop mobile applications. The last article covered how to accomplish this using native iOS development tools. In this article, we’ll look at how to build the same sort of application using native Android tools.

We’ve been building a simple tip calculator. As with the iOS application, this one contains two screens: a main view and a settings view. The settings view persists the default tip percentage to local storage using Android’s SDK support. (The source code for each app is available on GitHub.)

Native Android Development: The Tools

For the Android platform, the Java language is used, along with the Eclipse integrated development environment (IDE). Google provides the Android Developer Tools (ADT) plugin for the standard Eclipse IDE to support things like graphical layout definition and debugging. As of the time of writing, Google has also released a new IDE, calledAndroid Studio, in early-access preview. This product is based on JetBrains’ IntelliJ IDE and will eventually replace Eclipse as the official development tool for Android applications. Because Android Studio is still in prerelease form, we’ll use Eclipse to develop this application. Eclipse is very stable, and many Android training resources using Eclipse abound.

The Android development environment is supported on Windows, Mac and Linux. There is no charge for the development tools, and applications may be freely deployed to devices. To submit apps to the Google Play marketplace, developers must sign up for publishing and pay a one-time fee of $25. Submitting apps to Google Play is notably less involved than for iOS. When your application is submitted to Google, it is scanned for malware and common threats. Generally, the application becomes available to the general public within a few hours.

An overview of the toolset can be found on the Android Developers website. Successful Android development entails use of the following tools:

  • Eclipse IDE
  • Android SDK
  • Android ADT
  • Android system images for the Android emulator
  • an Android device (technically not required but highly recommended)


In the past, you had to download, install and configure the tools individually. This took a fair amount of time and often led to confusion for new Android developers. To make the process easier, Google now offers “bundles,” which simplify the installation process. Bundles are offered for each operating system and are available on the page where you download the developer SDK.

Installing Eclipse, the SDK, the emulator and so on is as easy as unpacking a ZIP file into a directory. If you have an existing installation of Eclipse and would prefer to use that instead, there are instructions for adding Android support to it.

Loading An Existing Application Into Eclipse

Once the Android development tools have been installed, you may wish to import an existing project, such as the source code for our sample app. In Eclipse, go to File → Import in the menu.

Once you’ve chosen the option to import an existing Android project, click the “Next” button, whereupon you will be able to specify the directory where the code that you wish to work with in Eclipse is located.

Once you’ve selected a directory via the “Browse” button, Eclipse will automatically find any Android project in that directory and show it in the list of projects to import. Simply click the “Finish” button, and the project will appear in your list of projects along the left side of the IDE.

Steps To Building An Application

There are several steps to building an Android application. We’ll cover each in detail later in this article. The steps include the following:

  1. Define the user interface. The UI for an application is generally defined as a series of layout files. These are XML-based files that describe the controls on a screen and the relationship of their layouts relative to one another.
  2. Add image assets, language translations and other resources. Android refers to non-code assets of a project as resources. These are placed in the project in a directory structure defined by the Android SDK. At runtime, Android dynamically loads content from this directory structure. We’ll see later on how different assets and layouts can be loaded to support the wide variety of Android device configurations available in the market today.
  3. Write Java code to respond to various events that occur from the controls on a given screen and from changes in the lifecycle of an application. Java code is also responsible for loading the layout and menu files associated with each screen. And it’s used to control the flow from one screen to the next.
  4. Export the completed Android application as a file that can be uploaded to Google Play or shared with others directly.

The Eclipse ADT For Android Development

The Eclipse IDE provides the standard source-code editing tools, along with a source-level debugger that allows applications to be debugged on both the simulator and a physical device. In contrast to the storyboards used with iOS, a layout editor is used to define screen layouts

The layout editor works on a single screen at a time and is not able to define segues between screens, as in the iOS storyboard editor. However, the Android layout editor does have a very flexible layout system that supports the wide range of screen sizes and resolutions of Android devices.

Unlike the storyboard editor in iOS, you can edit the layouts in either visual mode, as shown above, or an XML-based editor. Simply use the tabs at the bottom of the layout editor to switch between the two views. As the layouts become more complex, being able to edit the layout files directly comes in handy. A snippet of layout XML looks like this:

<RelativeLayout xmlns:android=""
                tools:context=".MainActivity" >

            android:inputType="number|numberSigned|numberDecimal" >
        <requestFocus />

            android:text="@string/calculateTip" />


Android Resources: Support For Various Device Capabilities

The Android SDK was designed from the outset to support a wide variety of device capabilities. Much has been written about the “fragmentation” of devices on the Android platform. However, from the beginning, the Android SDK was designed to support this variety of device attributes, including screen size, pixel density and Android API versions.

Screen layouts, image assets (called drawables), styles and other configuration files are all incorporated in a series of subdirectories underneath a master “resource” directory. The Android SDK documentation illustrates how multiple versions of the same file can be placed in uniquely named directories within this resource structure, so that the proper one is loaded depending on the capabilities and orientation of the device at runtime.

The structure above shows uniquely named directories for drawable assets, with suffixes of -hdpi-ldpi-mdpi and so on. This permits the developer to supply different image content to correspond with the DPI resolution of a given screen. Similar capabilities extend to things like the layout files, which may supply unique content according to screen size, landscape or portrait orientation, etc. In the example above, we see unique folders for values-v11 and values-v14. This allows for two different styles.xml files to be used for version 11 (Android 3.x) and version 14 (Android 4.x) of the Android operating system.

Note, also, the regular values directory. Android versions prior to version 11 would obtain their styles.xml from this directory. This fallback mechanism is in place for all resources. The SDK will attempt to find the resource in the particular directory and then fall back to a more “generic” resource if it’s not available. All of this occurs without the developer having to write any special code. Simply drop the resources into the proper directories, and the Android runtime will take care of the rest. Each of your resources may be accessed from both the XML and Java files in your application.

The resource system is quite powerful and supports many types of resources. In addition to the drawable, layout, menu and styles for your application, it can also be used to hold application constants for arrays or dimensional values in your application. In this manner, you can load different constant values for various device configurations simply by placing the files in the proper directory structure. You can also use this system to support localization. This is accomplished through thestrings.xml file. Here’s an example of the strings.xml file associated with our application:

<?xml version="1.0" encoding="utf-8"?>
    <string name="app_name">FasTip</string>
    <string name="hello_world">Hello World!</string>
    <string name="menu_settings">Settings</string>
    <string name="billAmount">Bill Amount</string>
    <string name="calculateTip">Calculate Tip</string>
    <string name="tipAmount">Tip Amount</string>
    <string name="totalAmount">Total Amount</string>
    <string name="title_activity_settings">Settings</string>
    <string name="saveSettings">Save Settings</string>
    <string name="tipPercentage">Tip Percentage</string>
    <string name="percentSymbol">%</string>

The base string file is placed in the res/values directory of the application. If you wanted to offer a Spanish version of the same file, you would place it in theres/values-es directory.


In the process of defining the layouts, you should associate an ID value with each control (or UI widget) that you wish to reference from code. This can be done by specifying an ID value in the properties inspector in the layout editor

Layout Managers

Android layout files may use a number of layout managers, or ViewGroups, to arrange the controls on the screen. This is Android’s approach to laying out views, much like the constraints system we saw in iOS. Here are some of the more common ViewGroups used in Android apps:

  • LinearLayout
    This is used to lay out a series of controls in either horizontal or vertical orientation.
  • RelativeLayout
    This is used to position controls relative to one another or to the bounds of their parents’ layout. This is a flexible layout system and is often used as an alternative to nesting linear layouts.
  • ListView
    This is a view group that presents a series of vertically scrolling items, much like a UITableView for those familiar with iOS. In Android, you write aListAdapter to provide a view for each row of data in a data source.
  • GridView
    This is similar to a list view, but it provides items in a two-dimensional, scrollable grid. Just like the list view, it also uses an adapter to provide view contents for each cell in the grid.

In our sample application, two layout files have been created: activity_main.xml for the main screen and activity_settings.xml for the settings screen. So far, we’ve just defined the appearance of things. Unlike the iOS storyboard editor, Android has no “assistant” tool to directly link the controls in the visual layout editor to the code. We’ll need to write some code to connect these components together and build the application.

Android: Activities And Intents

In iOS, we loaded the logic specific to a given screen into a ViewController. In Android, these separate screens are treated as separate “activities.” Just like in an iOS UIViewController, there is a defined life cycle for an activity that governs when the activity starts, pauses, resumes and stops.


The diagram above comes straight from the Android Developers documentation and shows the lifecycle of an activity. It’s up to the developer to place code in the various methods of the activity to respond to the various states of the lifecycle.

protected void onCreate(Bundle savedInstanceState) {


    tipPctTextView = (TextView)this.findViewById(;
    tipAmountTextView = (TextView)this.findViewById(;
    totalAmountTextView = (TextView)this.findViewById(;
    calcTipAmountButton = (Button)this.findViewById(;
    billAmountTextView = (EditText)this.findViewById(;

    calcTipAmountButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

The code above is executed early on in the activity’s lifecycle. In this case, we are loading the layout file that was defined earlier, via this statement:


Upon successfully loading the layout, we obtain references to the various controls that make up the layout. Notice that we are referencing the layouts and the IDs via the R. notation. These are the resource IDs that we defined earlier in the layout manager. Additionally, we attach a click listener to define what code should run when the user taps on the “Calculate Tip” button.

In the iOS example, we used NSUserDefaults to save and restore the user’s preference for a tip percentage. In Android, the equivalent is sharedPreferences. This can be seen in the code snippet below, where we restore the persisted value fortipPercentage in the local variable tipPctString. Notice that the first time the user runs this app, a default value of 15.0 is used.

private void loadTipPercentage() {
    SharedPreferences preferences =
                this.getSharedPreferences("AppPreferences", MODE_PRIVATE);
    String tipPctString = preferences.getString("tipPercentage", "15.0");
    tipPctTextView.setText(String.format("%s%%", tipPctString));
    tipPercentage = Double.parseDouble(tipPctString) / 100;


Android applications do not use the NavigationController approach of iOS applications. In Android 4.x devices, the choices that appear in the upper-right of the screen are part of the Android “action bar.”

The action bar is the dark header in this screenshot. Note the settings button in the upper-right, which is defined by the menu.

We populate the action bar by defining a series of menu options in an XML file, just as we did with the screen layout. The menu is placed in a menu directory within the resources directory. Here are the contents of the menu file used on the main screen of our application:

<menu xmlns:android="" >

Note that, in this case, we have just one menu option to access the settings screen. If more options were placed in the menu than could fit on the screen, then the remaining items would flow into a drop-down menu, accessible via the three vertical dots often seen in Android menus. To use the menu in our activity, we must load it at the correct time. This is done in the onCreateOptionsMenu method:

public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu);
    return true;

// Respond to menu selections
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
            return true;
            return super.onOptionsItemSelected(item);

Notice how the onOptionsItemSelected method is used to determine what code is run when a given menu option is chosen.

Starting Another Activity

As we’ve seen from the code above, when the user chooses the settings icon from the action bar, the startSettings() method is invoked. This is the code that launches the second activity to display the settings screen:

private void startSettings() {
    Intent settingsIntent = new Intent();
    settingsIntent.setClass(this, SettingsActivity.class);

Android launches activities via an intent object. In this simple example, we are creating a very specific intent to launch the SettingsActivity class, which contains the code to load and drive the settings screen. Most Android applications use this technique to move the user from one screen to the next in an application.


Intents are considerably more flexible than this. It’s possible to use intents to launch a variety of activities. A common intent is to send an item to be shared via social networking apps. If you’ve used an Android device before, then you’ll know that doing something like this typically brings up a menu of applications that support a sharing intent. This list often contains applications such as Facebook and Twitter.

This particular sharing intent is known as ACTION_SEND. All of the applications that support sharing are listening for a common intent. When an Android application is installed on a device, its manifest file describes the intents it can process. In this way, several applications may be installed, each of which supports the same intent.

If only one application supports the intent, then that activity is immediately launched. Whereas if multiple applications are installed for the same intent, then Android would show a menu of options, from which the user would make a selection before the intent is sent to the chosen activity.

The intent system in Android is a unique feature that can be used to create workflows across several applications. When building for the Android platform, you should keep this capability in mind because it offers a way to integrate your application with others.

The Settings Screen

Much of what occurs here has already been covered in the section on the main activity. This activity has similar code in the onCreate method to load the appropriate layout file and obtain references to the controls. When the “Save Settings” button is pressed, the following code is run to save the tip percentage value to storage:

private void saveSettings() {
    if (validateSettings()) {
        SharedPreferences preferences =
            this.getSharedPreferences("AppPreferences", MODE_PRIVATE);
        SharedPreferences.Editor prefEditor = preferences.edit();

Notice that the last line in the saveSettings method calls the finish() method. This causes the current activity to stop running and returns the user to the prior activity, which in our case is the main screen. Contrast this with iOS’ use of theNavigationController and the way we popped the current view controller off the stack of view controllers.

Running Your Application

Android provides two basic ways to test an application: in the Android emulator or on a regular device such as a phone or tablet. Unlike with iOS, you don’t have to pay any fees to deploy your app to your own device or to share it with other Android users. The only fee that is required is if you wish to feature your app in Google Play.

The emulator enables you to emulate a variety of Android versions, as well as different screen aspect ratios and resolutions. While testing your application on a real device is always a good idea, the emulator helps you to test on device configurations that are not readily available.

To use the emulator, you must create an Android Virtual Device (AVD). Think of this as a virtual phone or tablet. Creating multiple AVDs, each with a unique configuration, is possible to test your app on different screen sizes and memory capacities. Android Developers provides details on how to use the AVD manager to set up these devices.


The Android emulator has long been maligned for its poor performance on many machines. This is because, in the past, the emulator has been running actual code compiled for the ARM processor on a phone, rather than for the x86 CPU that’s likely on your development machine.

Recently, an x86 hardware-virtualized version has been made available. This version starts up and runs considerably faster than the traditional emulator. The hardware-virtualized version will generally run on a Windows or Mac OS X machine with an Intel Core i3 or later processor that supports hardware virtualization. AMD processors are currently supported only on Linux.

Creating an AVD that uses hardware virtualization requires that you set up Intel’s HAXM support first. The developer documentation provides details on the process to follow for your operating system. Make sure that you are running the latest HAXM support; if you’re on Mac OS X Mavericks, a recently released hotfix resolves issues there as well.


To test the application on your own device, you’ll need to enable USB debugging on the device. Google provides detailed instructions on setting up your device for debugging.

For Android 4.0 devices, go to Settings → Developer Options in the menu and you’ll see a checkbox to enable this. If you’re on Windows, you might need to install some USB drivers for your device; these can usually be downloaded from the manufacturer’s website. For Mac OS X, you usually will not need any drivers and can just plug in the device via a USB cable.

The Eclipse IDE provides a “targets” option that enables you to specify which device, or AVD, should be used to run your application. This can be found in Run → Run Configurations and Run → Debug Configurations in the menu. The “Targets” tab allows you to select which AVD should be used by default or to set a prompt each time to select a run or debug destination for the application:

If you select “Always prompt to pick device,” then the IDE will present this dialog each time you choose to run or debug the application

Every time you run or debug the application, an APK file is built and written to the/bin directory of your project’s root directory. This is the application distribution package used for Android devices. It’s analogous to the IPA file for iOS applications. When you select a deployment target via the process above, the Android development tools will automatically install the APK on the target device or emulator and run it.

Sharing Your Application With Others

Submitting an application to Google Play is beyond the scope of this article. The documentation provides an overview of the process. You can also use the export wizard in Eclipse to export an APK file. The resulting APK file can then be shared with others outside of Google Play via open distribution, and it is very useful when sharing copies of your application for testing prior to general release.

Android: Learning Resources

As with iOS, some excellent resources exist for getting started with Android. I recommend the following books and websites:

  • The Busy Coder’s Guide to Android Development, Mark L. Murphy
    This book is comprehensive, and the writing style is easy to follow. The author even offers a free version of the book based on an earlier version (Android 3.x) of the SDK.
  • Beginning Android 4 Application Development, Wei-Meng Lee
    For those looking for a shorter book, this does a good job of covering the basics, without as much detail or scope as Murphy’s book above.
  • Vogella
    This series of brief tutorials shows how to perform common operations in Android applications.
  • Android Weekly
    This weekly newsletter will help you stay current on new blog posts and libraries of interest to the Android development community.


That wraps up our coverage of developing a native app for Android. We’ve seen some unique capabilities of the platform, such as the resource system, layouts, and the way that activities and intents work together. In the next article, we’ll take the tip calculator cross-platform, looking at what’s involved in developing our app for both iOS and Android using PhoneGap.

Android Apps Trending

Why developers choose Android

So you’ve got an idea for an app? For those aspiring to occupy a small portion of digital real estate in the pockets of countless smartphone users, this is an important step. But before the first line of code can be written or the IPO is filled, there is another equally important consideration which must be made. “Which platform do I develop for?” While the answer seems fairly obvious to those of us who frequent this particular online destination, the decision to develop for one platform over another can weigh on more than just your heartstrings. So why do developers choose Android?

The Numbers


Android has enjoyed a meteoric rise to the top in its short lifespan, and it is no secret that it currently dominates the mobile market in number of active users. Its market share now hovers around 80% globally with Apple left holding a remaining 13% slice of the smartphone pie. BlackBerry, the once reigning king, and Windows Phone are merely the crumbs. There are also no signs of slowing down for Google’s mobile platform as it currently reaches 1.5 million daily activations. Such rapid growth has also helped Android reach the impressive milestone of 1 billion device activations.

For any developer looking to maximize their potential users, regardless of language or country, Android is an obvious choice. It is evident that developers have been making that choice too. As its market share has steadily risen since being introduced in 2008, so have the number of available apps. While actual numbers vary widely by source, Android and iOS seem to be neck and neck in total number of apps available-just around 900,000 each. We can also expect an impressive (however inflated) update from Google in the coming weeks with the impending announcement of a new Nexus device or devices in conjunction with Android 4.4 KitKat. Those who may want to jump ahead a little and fact check are free to reference AppBrain’s daily statistics, which have the Google Play store measured at 875,462 apps as of this writing.

Screen Shot 2013-10-24 at 11.04.04 PM

While developer interest can be gleaned in part from the numbers alone, there is still more that has contributed to the staggering number of applications now available for our favorite mobile platform.

History Lesson

A little-remembered fact is that the original iPhone did not launch with an app store in 2007. However, developer interest in creating native apps was apparent and the “first” mobile app store launched on the iPhone 3G in July, 2008 carrying with it around 500 applications. Apple’s heavy oversight of its App Store was criticized from the beginning, paving the way for how developers would receive Google’s own offering later that year. When the T-Mobile G1 launched on October 22, 2008 it boasted only a handful of apps compared to the iPhone’s nearly 7,500.

Android however, won praise early on for it openness. Supported at least in spirit by launch partner T-Mobile, the open nature of the Android platform helped position it as the anti-Apple. While both platforms grew steadily, the iPhone quickly became associated with a higher cost to consumers. Apple’s App Store boasted numbers and it also came with a price of $0.99 and above for the majority of applications. Combine this with devices costing upwards of $400 for a larger storage option and the iPhone’s exclusive availability on AT&T-not the cheapest carrier overall-Android, with its smaller but mostly free Android Market and more competitively priced availability, quickly made it stand out as the Robin Hood in the Sherwood Forest of smartphones.

Open and Versatile

Sharing in Android 4.3Most developers by their nature, like to tinker. Android early on, offered many potential “problems” in need of solutions. One of Android’s obvious differences has been it’s lack of exclusivity to one device. The operating system is designed to be free and open; Able to be used on a wide range of hardware with varying screen sizes and button arrangements. Not only does this allow hardware manufacturers to adapt the software more specifically to their device, it also presents a challenge to (hackers or) developers who may disagree with some of these changes or have ideas of their own.

Android started as a frontier for developers to dig deeper. The OS allows for greater access and customization which has spawned whole new categories of apps. Don’t like the keyboard that shipped on your device, or need a better calendar widget to go on your homescreen? Even the homescreen itself, or launcher, is essentially an app which can be replaced with one of the many innovative options from the Play Store. This “personalization” category (the 2nd most popular) accounts for just under 90,000 of the Play Store’s total applications and boasts the highest number of paid apps-giving some insight into just how healthy the user demand is for these types of applications. Widgets, live wallpapers, launchers and icon packs have long been favorites of the more capable users and have been a major differentiator for Android in general from its beginning.

Android also allows for a greater level of integration, both between separate applications and with the OS itself. Consider tapping a camera icon within one app to add a photo and being presented with all the camera apps on your device to take a picture, or having the ability to browse a third party file manager when adding attachments to Gmail.

These choices can be more limited on other platforms such as iOS, where sharing options are hard coded and tied to the operating system (and licensing agreements). Apple requires all applications to run in what they call a “sandbox”, which limits access to other apps and most parts of the OS. This essentially comes down to a differing philosophical perspective, that limiting applications’ access to a specified set of permissions across the entire OS, makes for a more secure experience. Android handles this particular security concern by informing users of the types of permissions each application has access to before installing or upgrading ultimately giving more choices to the user and the developer.

Google’s own apps and services are another great example of where Android really shines. Google Location Services for example, can allow applications to display and find maps, navigation and other data that can be deeply integrated into your own apps. Google cloud messaging is a service that can be leveraged by developers to deliver push notifications to a device while allowing their app to remain power efficient by not continually running in the background. And Google App Engine provides a fully functional cloud computing platform with certain levels of access starting at the low low price of free. App Engine can be used by developers to enlist greater processing power and free up on-device resources. Google continues to iterate and advance its ecosystem and all this offers greater incentives to attract developers to the Android platform.

Ease Of Access

ios vs android vs windows phone vs bb10 developer mindshare q2 2013

For the novice, the entry point for development on Android is simple and welcoming. Those who are familiar with iOS and have likely paid the $99 annual enrolment fee, might be surprised at the $25 one-time registration fee for Google Play. From there, developers have have complete control over distribution with options that allow them to target specific devices, carriers, languages and countries. Newly published apps on Google Play are also available almost instantly, due primarily to Google’s automated approval process. There is of course still a bit of the honor system in play here in regards to publishing content that is or is not allowed, but for stability and security, Google is able scan an application and approve it within a matter of hours rather than weeks as with iOS. However, algorithms aren’t the only line of defense in protecting users from “bad” applications, as Google has been known to regularly remove apps that violate Play Store terms and conditions.

Looking forward


In today’s mobile consumer environment, the best possible chance for developers to win widespread adoption of their app/apps is to utilize a two platform strategy. Market share in the United States is more equally split between iOS and Android. While Android still takes the top spot, its lead is far less dramatic. Apple remains the dominant handset vendor with just over 40% of U.S. smartphone subscribers. While Android takes the top platform, its distribution on a wide range of devices makes it more of a utility than a brand and therefore leaves it lagging in mindshare behind its brushed aluminum rival. Despite this fact, Android’s position as the dominant mobile platform is a testament to its ease of access to developers and users. For those who desire a greater level of control over their apps and devices, a better option cannot be found. Whether you aspire to mainstream success with the likes of Snapchat, Vine or Candy Crush Saga, or identify more closely with underground successes of Beautiful Widgets and DashClock, it is likely that Android offers whatever it is your are looking for.

How to Reply to Messages While You’re Busy with SMS Replier for Android

At a time when virtually everyone has a cell phone, it’s almost inconceivable to think of a time when we’re without them. At work, in bed, and even in the bathroom; we’re always with our smartphones. I mean, hell, someone even designed a way to bring your smartphone into the freaking shower.

It’s not THAT serious.

While we may have our phones just about everywhere, there are times when we have to put or devices away and get back to the real world. While driving, in class, during court and while playing sports are all times when your phone should be safely put away from distraction.

Even though your phone is put away, that doesn’t mean that the phone calls and text messages stop. My mom is the type of person who texts, then calls if i don’t respond within 10 minutes. If I don’t pick up the call, she’ll keep calling over and over and over and over…

Mom, ssssssssssttttttooooooooopppppppp!

She just won’t stop until she knows I’m safe. Even if I told her I was at a library studying. Did I mention that I’m in my early 20’s?

So how can you and I stop my mom (and all other moms) from freaking out so much and thinking we’re dead?

SMS Replier

SMS Replier is an app for Android, which responds with a personalized text whenever you receive a phone call or text message. It has a very simple user interface and is easily accessed through the notification status bar, when enabled.

All you need to do is just type in the message you want the phone to send and leave it to do its job. The notifications will post to the status bar and let you know at what time the messages were sent, who they were sent to, and whether or not they were sent successfully.

Now you can feel free to leave your phone alone while you’re busy skydiving or whatever.