vetalitet
vetalitet

Reputation: 703

android onTouchEvent. Different behaviour on different android versions

I have simple activity:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.d("Event: ", event.getAction() + "");
        return super.onTouchEvent(event);
    }
}

When I tab on screen (just put finger on the screen without any moving) onTouchEvent is called but has different result on android v4(4.2.2 or 4.4.2) and v5 (5.1).

on Android 5.1:
Event: 0 // this means ACTION_DOWN

on Android 4 (4.2.2/4.4.2):
Event: 0
Event: 2
Event: 2
Event: 2
...
Event: 2
Event: 2
...

so ACTION_DOWN and a lot of ACTION_MOVE.

I don't really understand why it happens. should I override some additional methods?

UPDATED

  1. Android 4.2.2 (Samsung Galaxy Tab 3)
    Tab on screen. Result:
    .0. (X, Y): 291.4858, 500.48877
    .2. (X, Y): 289.98328, 498.9873
    .2. (X, Y): 290.48413, 498.34665
    .2. (X, Y): 290.48413, 499.50812
    .2. (X, Y): 289.15115, 499.4878
    .2. (X, Y): 287.6314, 499.4878
    .2. (X, Y): 286.37064, 499.4878
    ...

  2. Android 5.1 (ASUS Nexus 7)
    .0. (X, Y): 528.5714, 813.4286
    stop. nothing happens here. I do a tiny finger moving:
    .2. (X, Y): 537.51135, 816.00323
    .2. (X, Y): 538.3928, 814.7871
    .2. (X, Y): 538.3928, 813.8571
    .2. (X, Y): 538.866, 813.4286
    .2. (X, Y): 539.7322, 813.4286
    ...

As for me, result on Nexus 7 is better. More logically. Interesting, is it possible to achieve, somehow, similar result on Samsung Galaxy Tab 3? By the way, the same result is on the other Samsung devices: GalaxyTab 4 and smartphone S4. Maybe it's a problem of Samsung devices.. Hm

Upvotes: 1

Views: 153

Answers (2)

Marcos Vasconcelos
Marcos Vasconcelos

Reputation: 18276

This is the expected behaviour, the subsequent MOVE calls is your finger "unprecision" to hold stoped.

Upvotes: 0

Gabe Sechan
Gabe Sechan

Reputation: 93569

Its probably just different sensitivity of the touch sensor. Even when you don't move your finger purposely, you have small movements and pressure changes which will cause differences in capacitance. Those differences in capacitance will be interpreted differently by different hardware, and some touch screens will think you've made a small move while others won't. Physical hardware isn't always exact like software.

Upvotes: 1

Related Questions