Android multi-touch on supported devices

let's say I would like to have an image in my application with scaling, is it possible to add event listeners with several devices to phones that support multi-touch (API 7+), and do zoom buttons appear on older phones?

Can this be done in one version of the application or do I need several versions of applications and several APKs?

+3
source share
2 answers

In this case, you do not need multiple APKs.

You can check for multitouch in the code:

if (Integer.parseInt(Build.VERSION.SDK) >= 7) { PackageManager pm = context.getPackageManager(); boolean hasMultitouch = pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH); if (hasMultitouch) { // set multitouch event listeners } else { // set zoom buttons } } else { // set zoom buttons } 

You can get the PackageManager from your activity (service) without using context : PackageManager pm = getPackageManager();

There are three types of multitouch that you can check.

Update: You should check the API version before checking the availability of multi-touch. FEATURE_TOUCHSCREEN_MULTITOUCH is only available from API 7. I updated the sample code.

+9
source

you can check your api level when starting your application and set the correct listeners and buttons on this information.

may this site be useful to you

Example:

  if(Integer.parseInt(Build.VERSION.SDK) >= 7) { //add multi touch listeners } else { // add zoom buttons } 
0
source

All Articles