Android - Detect Touch Pressure on capacitive touch screen?
Asked Answered
D

1

12

I've heard of:

MotionEvent e;
float press = e.getPressure(...);

But this only returns 0 for no touch, and 1 when my finger touches the screen.

Is it possible to find a value for the amount of pressure your finger is putting on the screen with touch capacitive screens?

Or is my hunch correct that this will only work with resistive screens..?

Delisadelisle answered 9/7, 2013 at 4:41 Comment(2)
What kind of devices returns 1? A virtual device in Android Emulator? Or a real device? What model?Toiletry
I've just noticed the answer to my question in your other comment: a Samsung Galaxy S3.Toiletry
B
16

MotionEvent().getPressure(i) should return a value between 0 and 1 based on the "pressure" placed on the screen. In reality for capacitive screens it is the size of the capacitive object rather than literal pressure, but the concept is almost the same for fingers (fingers are squishy). Ranges higher than one may be returned depending on the calibration of the touchscreen.

If your screen is only returning 0 or 1, try testing on another device. Perhaps your screens driver simply does not return those values.

MotionEvent | Android Developers : getPressure()

Bitartrate answered 9/7, 2013 at 5:0 Comment(3)
Interesting. So it's actually measuring the amount of contact on the screen as your finger squishes down on it. I'm not sure, I'm using a Samsung Galaxy S3.Delisadelisle
This is a bug in Samsung Galaxy S3, the screen only returns either 0 or 1. For a list of devices that do not support pressure, see: code.google.com/p/markers-for-android/wiki/DeviceSupportHisto
But how can I incorporate this pressure using a TOUCH_DOWN event only? It doesn't update until I move my fingerStringent

© 2022 - 2024 — McMap. All rights reserved.