title: Android vibrate while button on hold
body: <p>Help please. Here is what I am trying to achieve, I have this button that when I click it will vibrate phone on depending on how long you press the button. </p>
  
  <p>like you hold the button for 5 seconds the vibrate will be 5 seconds.</p>
  
  <p>just like a <strong>throttle</strong></p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Button b = (Button) findViewById(R.id.start);
      b.setOnTouchListener(new OnTouchListener() {
  
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              // TODO Auto-generated method stub
              Vibrator vb = (Vibrator)   getSystemService(Context.VIBRATOR_SERVICE);
                  while((event.getAction() &amp; MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN){ 
                              vb.vibrate(100);  
                  }
              return false;
          }
  
      });
  }
  </code></pre>
  
  <p>in my code the vibrate is like this it stops every 100 ms. also it crashes the phone</p>
  
  <blockquote>
    <p>la la la la la la la la</p>
  </blockquote>
  
  <p>I want to achieve a vibrate that would be something like this. the longer you will click and hold the longer it will vibrate </p>
  
  <blockquote>
    <p>laaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
  </blockquote>