Monday, September 13, 2010

NTouch released on Android Market

My first app was just released on the Android Market. It's a very simple app that visualizes multi-touch capabilities (or incapabilities!) of any device that runs Android 1.5 or higher: http://www.appbrain.com/app/com.smedis.ntouch

Even in this little app, I learned quite a lot. I learned how to support multiple OS versions in a single APK (set target SDK high, set minSdkVersion low and encapsulate all version-specific code). Unfortunately there aren't any compiler help to spot incompabilities in the version-specific code. The code that was written for the old OS version don't trigger any compile errors/warnings if it tries to use a newer API. If it fails, it will fail at run-time. And there isn't any c-preprocessor to make it easy to compile differently. :/

Perhaps it's possible to make various test environments with Ant, separating code for Android 1.5 and make sure they compile fine in a pure Android 1.5 environment. Then another separation for code that's for Android 2.1 and test that path separately. Would be very neat. Need some ant XML magic here perhaps...

NTouch is pretty interesting when you turn on event logging... You'll see the original Droid do some weird things, especially when the second pointer hits. It'll incorrectly report the same position for both touches at that time, and subsequent MOVE events may switch the touch id. (It's possible that this is fixed in Droid's Froyo update...)

The precision and robustness also depends on whether you hold the device in your hand or not. When the device is lying on a table and isn't "grounded", your touches can generate weird results...

With event logging turned on, you can also see what happens when the orientation changes. The app is actually shut down and restarted by the OS. However, all current touches are lost in the transition. If you keep a finger on the screen during an orientation change you'll stop receiving any more touch events. You'll have to release the finger and put it back on the screen to start generating touch events again. Seems like an OS issue.

No comments:

Post a Comment