you could try something like this
getPackageManager().hasSystemFeature("android.hardware.touchscreen");
but that's been stated to not always work, specifically when a device is connected to a tv or other screen through hdmi, since it deals with the android player itself and not the connected device, but it should work for your needs.