title: How to implement onTouchEvent with a FragmentActivity
body: <p><strong>My Question:</strong> Is there a work-around for using an onTouchEvent in a FragmentActivity?</p>
  
  <p><strong>My Situation:</strong> I'm writing a simple flashlight app and I have a FragmentActivity where a user can swipe between colors (the whole screen is just one color. This app is for personal improvement). I want to be able to do a <code>onLongPress</code> event for options, a <code>onDoubleTap</code> event for hiding the navigation bar, and <em>most importantly</em> a touch event to control brightness of the app (I want to let the user scroll up and down for brightness changes, any ideas here are welcome! is the <code>onFling</code> event good for this?)</p>
  
  <p><strong>What I've tried:</strong> I have a <code>GestureDetector</code> with my implementation of an <code>SimpleOnGestureListener</code>. I override the <code>onTouchEvent</code> in the <code>FragmentActivity</code>, but I have just found out that this method is never called in a <code>FragmentActivity</code> (I also tested this with a <code>Log.print</code> in the method and it's never called). Is there a work-around? Thanks!</p>
  
  <p><strong>Salient Code:</strong></p>
  
  <p>MainActivity:</p>
  
  <pre><code>public class MainActivity extends FragmentActivity {
  
    private GestureDetector gestureDetector;
    private FragmentPagerAdapter mAdapter;
  
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      gestureDetector = new GestureDetector(getApplicationContext(), new MyGestureListener(getWindow()));
  
      mAdapter = new ColorFragmentAdapter(getSupportFragmentManager(), getDefaultColorList());
      ViewPager pager = (ViewPager) super.findViewById(R.id.viewpager);
      pager.setAdapter(mAdapter);
      pager.setCurrentItem(Math.round(mAdapter.getCount() / 2)); //Set current fragment to middle fragment
    }
  
    @Override
    public boolean onTouchEvent(MotionEvent event) {
      print("Sending touch event to gestureDetector.");
      //This line is never run.
      return gestureDetector.onTouchEvent(event);
    }
  
    /**
     * Prints the given object to the log with the debug priority with the tag FLASHLIGHT
     *
     * @param object
     */
    public static void print(Object object) {
      Log.println(Log.DEBUG, "FLASHLIGHT", object.toString());
    }
  }
  </code></pre>
  
  <p>MyGestureListener :</p>
  
  <pre><code>public class MyGestureListener extends SimpleOnGestureListener {
  
    private final Window window;
  
    public MyGestureListener(Window window) {
      super();
      this.window = window;
    }
  
    @Override
    public void onLongPress(MotionEvent e) {
      //onLongPress code
    }
  
    @Override
    public boolean onDoubleTap(MotionEvent e) {
      //onDoubleTap code
    }
  
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
      //onFling cod
    }
  }
  </code></pre>
  
  <p>main.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    &gt;
    &lt;android.support.v4.view.ViewPager
          android:id="@+android:id/viewpager"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I don't think you'd need anything else to answer the question, but let me know if you do.</p>