Thursday, May 10, 2012

Multi-Touch (Pinch-zoom) support to Android Applications

In this post, i am going to explain the mechanism to enable the multi-touch support for Android applications.

Introducing multi-touch
Multi-touch is simply an extension of the regular touch-screen user interface, using two or more fingers instead of one. We’ve used single-finger gestures before, although we didn’t call it that.
Three common touch gestures .
a) Tap
b) Drag
c) Pinch-Zoom
With pinch zoom, you place two fingers on the screen and squeeze them together to make the item you’re viewing smaller, or pull them apart to make it bigger. Before Android 2.0 you had to use a clunky zoom control with icons that you pressed to zoom in and out . But thanks to its new multi-touch support, you can now pinch to zoom on Android too! As long as the application supports it, of course.
Enable the multi-touch for Android Applications
By default, all the android applications won't be enabled for the multi-touch functionality. You need to explicitly mention this feature in your AndroidManifest.xml file of the application. 
The applications like 'Browser', 'Maps' and 'Gallery' will usually require this feature.
 a) Include the below lines in your application manifest file
      <uses-feature android:name="android.hardware.touchscreen.multitouch"
                  android:required="true" />
b) Copy the respective multitouch.xml file onto /system/etc/permissions folder. This is an important step when we know that from the hardware side the multi touch is already supported. 
       Include the below lines in your file.
     PRODUCT_COPY_FILES := \  frameworks/base/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \
Refer for more info . (frameworks/base/core/java/android/content/pm)