Category: Uncategorized

  • Using adb over Wireless / Wifi

    Physical cables are rapidly becoming obsolete, and they’re annoying to use for Android development and debugging. Luckily, adb can easily be configured to work wirelessly and you can free yourself from micro-USB cables (almost) entirely. To do this, plug a phone into a computer as you would to normally debug over adb. (This is the…

  • Copy Android LogCat / Log Contents From a Device With adb

    It’s a bummer when your Android application crashes while you’re away from a computer. Luckily, there’s a simple adb command that will dump the contents of logcat’s ring buffer to your local disk, so you can examine the cause of the crash: [code] adb logcat -d -v time > logcat.txt [/code] This will copy the…

  • LightBox Effect for Android Dialogs

    The stock black rectangular progress dialogs on Android are ugly, so I created a simple little open-source alternative. It works by placing a translucent overlay on the Android UI with a ProgressBar and a dialog message. There’s also an alpha animation in there, to really class it up. To use it, just add the lightbox_dialog.xml…

  • Example Robolectric and Ant Eclipse Project

    Until recently, I’ve been unable to configure a Robolectric project that can easily be shared across a team and integrated with Jenkins CI without the use of Maven. I mentioned this in a previous post, and have asked for assistance on Pivotal’s Robolectric Google Group a handful of times. There are several jar files that…

  • Double-Tap to Zoom in Android Maps

    Double-Tap to zoom is a typical feature for mapped interfaces on Android. Sometimes it’s just annoying trying to reverse-pinch to zoom with one hand while holding a device. This is something that’s not technically difficult to do, but it’s not documented very well. Here’s how to do it: Write a class that inherits from MapView,…

  • Inspecting and Improving UI Layouts With HierarchyViewer

    HierarchyViewer is a visual tool that can be used to inspect your Android user interfaces and help you improve your layout designs and performance. It’s packaged with the Android SDK, and lives in the <android-sdk>/tools folder. To launch hierarchyviewer, simply open a terminal or command window and type hierarchyviewer. To open hierarchyviewer via Eclipse, select…

  • Unit Testing Android Applications With Robolectric

    Running unit tests on an Android emulator or device is slow! Building, deploying, and launching the application in an emulator often takes several minutes, and that’s painful. It’s downright unacceptable if you’re planning on running your unit-tests as part of a continuous-integration build process, because the build server will need to launch an emulator every…

  • Android Threading: Part 1

    The UI layer of all Android applications runs on a single thread called the UI thread. Performing long-running operations such as network access or database queries on this thread will block the user interface, and eventually crash your application with an Application Not Responding (ANR) error. In this tutorial I’ll show you a simple way…

  • Real-Time Android Messaging With Pusher

    Pusher is a hosted API for real-time JSON messaging in web and mobile applications via WebSockets. Examples Pusher applications: Updating a website or mobile application with sports scores or stock prices in real-time Sending real-time messages to Arduino devices from a web or mobile application Building a real-time donation thermometer on a website Tracking multi-player…

  • Avoiding Android Memory Leaks: Part 1

    I recently discovered how easy it is to accidentally “leak” memory and resources in an Android application. In this tutorial, I’ll illustrate a memory leak with a simple dialog box example, and then show you how to fix it. Let’s start by creating a simple Android application that displays a dialog in its onCreate event:…