November 26, 2014

Projecting Android on the Big Screen

Suppose you need to show off an Android application. Maybe you are making a VC funding pitch, or you are demonstrating for carriers at the upcoming Mobile World Congress, or you are explaining to a government agency how your Android app will simultaneously cure world hunger and keep tabs on area potholes.

The simplest thing to do when presenting Android to a large audience is to use the emulator, connected to a notebook, connected to a projector. This is quick, easy, and you may already have the projector if you do this sort of presentation a lot.

However, there are times when the emulator is insufficient. Perhaps the application needs actual GPS coordinates rather than faked values supplied by DDMS. Perhaps the application needs actual accelerometer movements rather than ones provided by a sensor simulator. Perhaps the application integrates with other applications that are on the device but not on an emulator (e.g., YouTube player).

You could buy or rent a device projector, but even this has issues if you need to be moving the device around (e.g., play an accelerometer-aware game).

Or, you can try DroidEx.

DroidEx extends the live device screen capturing technology built into DDMS and hierarchyviewer. It gives you a window displaying a live 6 fps (frames per second) perspective of the screen contents of an actual Android device. Since most of the work was done by the core Android team with their toolsmithing, DroidEx itself is about ~100 lines of very lightly tested code.

To get it, download the 3K JAR file from:

http://groups.google.com/group/cw-android/web/DroidEx.jar

To run it, you need to put it and the ddmslib.jar from your SDK tools/ folder on the classpath and invoke com.commonsware.droidex.DroidEx, such as:

java -cp DroidEx.jar:/opt/android-sdk-linux_x86-1.0_r2/tools/lib/ddmlib.jar com.commonsware.droidex.DroidEx

It also requires that the adb daemon be running, such as a development PC/Mac.

It assumes there is precisely one device plugged in or emulator running. All it does is open a window showing you the contents of that device’s or emulator’s screen.

It also suffers from the following limitations:

  • The screen-capture logic in Android proper seems to occasionally miss updates for some reason. I’ve seen this with DDMS and hierarchyviewer too, so I’m assuming it’s something in the Android firmware. Hence, sometimes DroidEx will appear to be a movement behind (e.g., you clicked up in a list, and DroidEx still shows the previous one as the selected item)
  • Once, adb or the device seemed to reject DroidEx part-way through a projection session, causing the image to freeze on DroidEx’s window and a bunch of error messages to be logged to stderr. Closing and reopening DroidEx was sufficient to clear up this condition.

Also, this was compiled against 1.0r2’s version of ddmslib.jar, so it may or may not work with other versions of the SDK.

DroidEx is a very quick and dirty hack, to solve a specific problem. It is far from perfect and may have any number of bugs. Eventually, I will clean it up and release it as open source, as there are a number of ways to extend DroidEx to make it even more useful, such as:

  • Doing a better job of packaging, so you don’t have to fuss with the classpath and manually specifying the class name
  • Allowing the frames-per-second rate to be set on the command line
  • Allowing you to specify which device/emulator to project, if there is more than one attached
  • Allowing you to save a session either as a set of still images (e.g., one every X seconds) or as a movie clip
  • Creating a server variant so the live animation can be viewed online

Questions regarding DroidEx should be asked in the CW-Android Google Group, the support area for the CommonsWare line of Android programming books and related bits of stuff.



  • http://www.androidtapp.com AndroidTapp.com

    This is awesome! Downloading now. I have some uses for device projections. Thanks!

  • http://www.extopian.com Tyler Onbekend

    Great proof of concept. Would love to see this as an average-user-friendly application. Does this require root like all the other screen capture solutions we’ve seen floating around out there?

  • http://commonsware.com/Android/ Mark Murphy

    @Tyler:

    No, this does not require root. In fact, there’s no software running on the device itself, beyond the standard stuff that’s already on there. DroidEx uses the same services that DDMS and hierarchyviewer use for their screen images.

    You’ll need the SDK installed on the projecting PC, so you have the adb daemon and such. But otherwise, that should be it.

  • richard

    I am very impressed and looking forward to your code release.

    However, lib/ddmlib.jar seems to be removed from SDK-1.5, so I guess it won’t work any more, right?

    ps. It works at SDK-windows-1.1_r1

  • http://commonsware.com/Android/ Mark Murphy

    I have not yet tried DroidEx with 1.5. There may be some changes needed.

  • klaus

    It works for me on 1.5 (on an HTC Magic)…

  • http://urbangolf.ignaz.at anton

    nice software! i used it to present my software on the viennese localcamp this weekend! i would love to have a zoom feature, could you get me the source-code, so i can implement this little feature?

  • dethx

    It's work on my ubuntu but not in Windows

    java -cp DroidEx.jar:D:Dataandroid-sdk-windows-1.5_r3toolslibddmlib.jar com.commonsware.droidex.DroidEx

    Do I missing something. Thanks for great great software.

  • devthx

    sorry for my fool. Fix it – replace : with ;

    java -cp DroidEx.jar;D:Dataandroid-sdk-windows-1.5_r3toolslibddmlib.jar com.commonsware.droidex.DroidEx

  • Rick

    Has anyone gotten this software to work on Android 2.0 or 2.1?

  • Cathleen

    Works fine with my HTC Tattoo (1.6) but not with Samsung Galaxy S (2.1). I guess it might be the SDK issue…
    Great app anyway.

  • WRSONG

    I’m just a little confuse or not up to task for this. It not friendly for a typical user. Guess I need a step by step or even video of how to do it. Any one want to make pictorial or explain the detail detail?

  • Pingback: Android Colombia » Proyectando dispositivos Android con un Video Beam

  • Stratis

    Very cool!

    I wonder if there a parameter to handle landscape mode?

    I guess there wouldn’t be since it’s accelerometer triggered (or device dependent).

  • Stratis

    Also it doesn’t seem to be running at 6FPS for me.

    I count 1-2 frames per second…

  • Einstein

    Kindly somebody tell as to how to make it work for the samsung galaxy series (galaxy tab or galaxy S) :)

    Thanks

  • Pingback: туроператор по израилю

  • Pingback: http://www.youtube.com/watch?v=p3fui3LdQDo

  • Pingback: http://answers.yahoo.com/question/index?qid=20130114023359AAgmE8v

  • Pingback: bande bromoil asideness