title: Android: Simplest way to calculate delta of touch position?
body: <p>I want to calculate the delta of touch positions on the screen. For that, I'm using this code:</p>
  
  <pre><code>public boolean onTouchEvent(MotionEvent event) {
      touchX = (int) event.getX();
      touchY = (int) event.getY();
  
      deltaX = touchX - oldX;
      deltaY = touchY - oldY;
  
      oldX = touchX;
      oldY = touchY;
  
      return super.onTouchEvent(event);
  }
  </code></pre>
  
  <p>Now, when I move the finger on screen for some time, I get the correct delta. But the problem occurs when I stop my finger, but don't lift it. At that time, I just get the non-zero delta of last frame. It is because <code>onTouchEvent</code> is not called when the finger is on screen but static. I should get zero delta when finger is static.</p>
  
  <p>What's the solution to this problem?</p>