I'm building an Android app where the user has to touch a circle on the screen, and I need to record how far away the user's touch was from the center of the circle.
Thing is, I want to record the physical distance, not the pixel distance, because I'm going to run this app on many devices and I want all the results to be uniform. For example, if the user's touch distance from the center of the circle is 15px, this could be a physical distance of 0.5cm on one device, and 1cm on another (just made up those numbers, but you get the idea). So I can only rely on physical measurements, not pixels.
So how should I record the touch distances? The View.onTouchEvent
method gives you the x and y of a touch event in pixels (I'm assuming), so do I just get the distance in pixels from the center of the circle to the touch, and then convert that to dp (and store all results in dp units)? Or should I convert the pixel distance to pt, which is supposed to be the same physical size on any device? If so, how does one convert from px to pt (I can't seem to find the answer to this anywhere)?