title: trigger ontouch event programmatically
body: <p>what i'm trying to do is trigger an ontouch event at a specific region on my activity when i receive a specific string from an arduino(via bluetooth). i trying to build a controller with a wii and an arduino to use in a game i'm writing myself. </p>
  
  <p>before you answer this  , i already know that there is  a function <em>*</em> openButton.performClick(); for this but in the game i'm not always going to be using buttons so its not good .</p>
  
  <p>i want to simulate a touch like the the adb does it with monkey, but without root permission
  something like inject touch just no root.</p>
  
  <p>this is part of the code:</p>
  
  <pre><code>    int[] loc = new int[2]; 
      openButton.getLocationOnScreen(loc);// get the region where to simulate the //touch event
      xTest = (float)loc[0]; 
      yTest = (float)loc[1]; 
  
  
  
  @SuppressLint("Recycle") void testing(){
      long downTime = SystemClock.uptimeMillis();
      long eventTime = SystemClock.uptimeMillis() + 100;
      float x = xTest;
      float y = yTest;
  
  
      int metaState = 0;
      MotionEvent motionEvent = MotionEvent.obtain(
          downTime, 
          eventTime, 
          MotionEvent.ACTION_UP, 
          x, 
          y, 
          metaState
      );
      dispatchTouchEvent(motionEvent);
  
  
  }
  
  @Override
  public boolean onTouch(View v, MotionEvent event) {
      // TODO Auto-generated method stub
       int action = event.getAction();
          switch (action &amp; MotionEvent.ACTION_MASK) {
              case MotionEvent.ACTION_UP:
                  // do something
                  openButton.performClick();
                  break;
              case MotionEvent.ACTION_MOVE:
                  // do something
                  // how to trigger a ACTION_DOWN event here?
                  break;
      }
  
      return false;
  }
  </code></pre>
  
  <p>so wenn i get a specific string i want to simulate a toucht event programmatically at a specific region on the screen, this time its a button , but it could be something else thats why "view.performclick()" is not good.
  I've seen some examples where before the dispatchTouchEvent they put view, if i do this i get an error
   thanks you in advance for your help</p>