title: Android Gesture Detection in class, call methods
body: <p>I try to detect the gestures in android and the it crashes all the time, i have problems with creating an constructor, i'am not so advanced in using classes</p>
  
  <p>this is the GestureDetector class, width all the necessary methods for the OnGestureListener: </p>
  
  <pre><code>public class GestureDetectorClass implements OnGestureListener {
  
        @Override
        public boolean onDown(MotionEvent arg0) {
            Log.d("Gesture", "onDown");
         return false;
        }
  
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,  float velocityY) {
            Log.d("Gesture", "onFling");
        return true;
        }
  
        @Override
        public void onLongPress(MotionEvent e) {
            Log.d("Gesture", "onLongPress");
        }
  
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2,
          float distanceX, float distanceY) {
            Log.d("Gesture", "onScroll");
         return false;
        }
  
        @Override
        public void onShowPress(MotionEvent e) { 
            Log.d("Gesture", "onShowPress");
        }
  
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            Log.d("Gesture", "onSingleTapUp");
            return false;
        }
  
  }
  </code></pre>
  
  <p>and in the main i try now to call the class / methods
  tried following code:</p>
  
  <pre><code>public class MainActivity extends Activity  {
  
  
      GestureDetectorClass myGestureClass = new GestureDetectorClass();
      GestureDetector myDector = new GestureDetector(this, myGestureClass);
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
      }
  
      public boolean onTouch(MotionEvent e) {
          return myDector.onTouchEvent(e);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <p>in the log i found this error:</p>
  
  <pre><code>    11-13 11:15:02.615: E/AndroidRuntime(1127): Caused by: java.lang.NullPointerException
  11-13 11:15:02.615: E/AndroidRuntime(1127):     at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:125)
  </code></pre>