title: Find duration between touch events in android
body: <p>I have set up an <code>onTouchListener</code> which allows the user to click <code>textView2</code> exactly 10 times, as shown below. My goal is to measure the time between touch 1 and touch 2, and store it as a variable, say <code>time1</code>. However, I'm not quite sure how to do this. One idea I had was setting up a variable, <code>i</code>, that measures the number of times the <code>TouchListener</code> was clicked. I was thinking of potentially measuring the time that <code>i</code> contained a particular value (for example, if <code>i</code> was equal to 1 for 1 second, this means the time between touch 1 and touch 2 was 1 second). However I'm not sure how to implement this, and I'm not even sure if this is the correct method. Does anyone know how to solve this problem?</p>
  
  <p><code>.java</code> file</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  int i;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      final TextView textView2 = (TextView)findViewById(R.id.textView2);
  
      i=0;
  
      textView2.setOnTouchListener(new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              if (event.getAction() == MotionEvent.ACTION_DOWN){
                  i++;
                  if (i==10) textView2.setOnTouchListener(null);
  
              }
              return false;
          }
      });         
  
  }
  </code></pre>