I am testing this sample on version 13 of android (3.2) and I have an issue when there is multiple touches on screen.
When I first touch, then there is an action_down event, if I make another simultaneous touch, then I won't get another action_down, my first touch keeps active and I can keep getting action_move from the first touch.
The problem is, when I release the first touch and move the second, it creates a line to that touch, because it generates another action_move event.
I tried using Euclidean distance, but it seems to slow down too much, and makes the lines incomplete.
I tried creating a producer/consumer model, but still got the same problem.
I also tried checking the time from the last touch, but this is very inefficient.
Does anyone have any suggestion?
I admit I'm a little confused about what your actual problem is, but it seems to me like your problem might be solved simply by handling more of the touch events. When the second finger comes down, you can get an ACTION_POINTER_DOWN event, indicating a second touch, and you can then modify how your ACTION_MOVE events will be interpreted while the second finger is down, until an ACTION_POINTER_UP event comes through. Hope that answers or at least helps your question.
Related
I'm working on an android application on tablet to draw every points touched by the finger or the hand. It is very important for the application to track not only the fingers but also the palm (even if it's not drawing the exact touched area but only a thin path, as long as we can see the movement of the palm it's fine). A good example of what I want to do is the "show pointer location" in the Android developer menu : if the drawing could be exactly like this, that would be perfect.
I managed to code a multi-touch drawing app, but the problem I have here is that every time the touched area is too wide (for example when I touch the screen with my entire palm), the application stops drawing (even the fingers drawings stops) and I have this error in the log : [ViewRootImpl] action cancel - 1, eccen:1.4225352 (the number after "eccen" changes depending on the size of my palm touch).
I'm quite new to android, I spent a lot of time searching how I could prevent this action_cancel but I couldn't find anything that makes it work... I tried to prevent the parent views from taking control of the onTouch events, but it didn't work. So if you have any idea of how I can manage that, it would be great :)
Thanks !
(English is not my native language, so don't hesitate to ask me to reformulate is something is not clear)
I asked a similar question before but the answer was not very helpful and I can't find any solution for this problem.
I want to know a method to detect ACTION_DOWN when we only touch a certain view and to detect ACTION_MOVE when we only move our finger on screen, because all I am getting is ACTION_DOWN and ACTION_MOVE being called at the same time when I place my finger on the view.
can anyone please post a simple code for how to do that.
That are raw motion events. You can probably use GestureDetector and detect click and swipe.
Problem is that ACTION_MOVE will be called when any move is detected, for example applying just a little more pressure when touching screen might move touch point few pixels around.
I am creating an Android game that uses touch input. I noticed that, when I put down a finger and move it, there is a threshold of a couple of pixels until the first MotionEvent.ACTION_MOVE is generated. What is the correct way of disabling this threshold filter?
It's called touch slop. And here's the same question already answered: Android ACTION_MOVE Threshold
The Android Gesture API is a real help and removes the need to reimplement a pretty complex wheel.
I however need the API to be more "responsive".
As way of an example. Lets say I define a Gesture, such as "Circle" in which a single finger gesture event is defined to be, yep you guessed it, a single finger circle.
If the user undertakes this gesture continuously, without lifting the finger, I would like for "onGesturePerformed ()" to be called repeatedly, ie the user continues to perform the same gesture.
I would like a firing granularity of maybe 1/4 second. I have seen a similar question but in that case the user wanted a longer delay and not a shorter delay where the user does not lift the finger.
Many thanks in advance.
Paul
I want to move an image around the screen according to the trackball movement. I am able to capture the movements using the onTrackballEvent method. But this is being called for very small float values (I believe for each rotation?) of the trackball.
Now as X and Y positions of views should be integers when specifying with LayoutParams, it makes no sense to move the view with every rotation. Instead I want to move the view only after the user stops rotating the trackball.
Is there any method by which we can get whether the user stopped using the trackball or not?
If there isn't (I don't know Android), the classic approach is to start a timer in each event, and keep track of the deltas reported in it (by adding them to a running sum, one for X and one for Y). On any subsequent event, before the timer has triggered, just re-start the same timer, pushing its triggering further into the future.
When the user stops generating events, the timer will eventually trigger, and then you can apply the sum of all the movements, and clear the sums.
A suitable timeout must be chosen so that the user interaction is not perceived as being too sluggish. Perhaps something on the order of 200-300 milliseconds, or more. This is easy to tweak until it feels "right".
I've also gotten a lot of value out of setting a threshold. So if the total movement in a specific direction adds up to a given amount, then trigger a navigational event.