Android WiFi Debugging

According to a post on xda-developers, you can enable ADB over Wi-Fi from the device with the commands:

And you can disable it and return ADB to listening on USB with

From a computer, if you have USB access already

It is even easier to switch to using Wi-Fi, if you already have USB. From a command line on the computer that has the device connected via USB, issue the commands

Be sure to replace 192.168.0.101 with the IP address that is actually assigned to your device.

Photo Collage Layout Algorithm

I’ve been thinking about writing an Android app that lets you view the photos on your phone in a new and different way. The idea is to cluster together images that are taken in close proximity to each other by time and location. I noticed from my own experience that I usually take pictures in sessions and each photo in the session is usually taken within 15 minutes.

So I have the general idea for how to cluster together my photos, now I need an interesting image layout algorithm. I stumbled upon a paper published by HP that outlines what they call the BRIC (Block Recursive Image Composition) algorithm. Check out section 4 for more details.

I wrote my own implementation of the BRIC algorithm in an Android app. Here are a few screenshots. I think it works pretty well.

Fix Debugging GDB Symbols

I was doing some C++ debugging on Ubuntu and noticed to find that non of the local symbols were being displayed in GDB. The only symbol available was std::__ioinit. After some digging I found the solution was to add -gdwarf-2 to the compiler command line:

Turns out this is because GCC 4.8+ now generates DWARF4 debugging symbols whereas older version of GCC generated DWARF2 symbols. The problem was my older version of GDB did not know how to use the newer DWARF format.

As noted in GCC 4.8 Release Notes:

DWARF4 is now the default when generating DWARF debug information. When -g is used on a platform that uses DWARF debugging information, GCC will now default to -gdwarf-4 -fno-debug-types-section.
GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 debug information consumers support DWARF4 by default. Before GCC 4.8 the default version used was DWARF2. To make GCC 4.8 generate an older DWARF version use -g together with -gdwarf-2 or -gdwarf-3. The default for Darwin and VxWorks is still -gdwarf-2 -gstrict-dwarf.

Enable running 32-bit programs on Ubuntu 64

Recently I installed a fresh version of Ubuntu on my 64-bit machine and got errors when running 32-bit programs. I found the solution was to install the 32-bit version libs.

Error:

Solution:

MiniWeb

MiniWeb is a Http server library written in Java targeted for embedded projects. MiniWeb’s goals are to be small and lightweight as possible while providing simple and easy to use API. MiniWeb uses the very mature and robust Apache HttpComponents at its core. MiniWeb only supports what is necessary to get an embedded web project up and running quickly (no servlets).

Checkout the MiniWeb GitHub page

Example Usage

Create a server that serves files from “public” folder:

Controllers

Handle request programmatically is very simple with Controllers. The following example will respond the a request for /cgi/hello with the text world.

Query params

Controllers can even handle URL query params. For example:

Sending a /cgi/hello?param1=cool&bananas=5 and the value of param1Value would be “cool” and numBananas would be 5 as expected.

You can also use parts of the url path as parameters like so:

JSON REST Requests

Controllers can also be used to handle REST requests without all the overhead of parsing JSON manually. For example:

performing a POST to this endpoint with json: { "name": "awesome!" }. Note: the request must have a Content-Header header value set to application/json.

JSON REST Response

sending a response with JSON is also easy. Just add the @Body annotation to your handle methods.

SmartHUD

smarthudSmartHUD is an Android app paired with a small cradle device that is mounted to the inside of your car windshield. The system delivers important information to the driver like navigation instructions and text messages in a non-distracting manner. The system is hands-free and works with voice commands. You can tell SmartHUD to navigate somewhere, respond to text messages, and control music with your voice and you never have to take your eyes off the road. I am one of the co-founders and Android app author.

Checkout me presenting a live demo of the SmartHUD system at Drinks on Tap Mobile Meetup in Boston (Sep 21, 2013)

Android Lightweight Timer

Introducing: LightweightTimer. LightweightTimer allows to schedule tasks for repeated future execution. It pretty much serves the same purpose of Java’s Timer class, but does not require extra thread creation. Instead, LightweightTimer uses Android’s Handler class to schedule its tasks. This is important when creating Android apps because memory is at a premium, and creating a thread for every little repeating task you have seems wasteful. Also, the LightweightTimer has the added benifit of executing on the main thread, which is often what you want.
Continue reading