title: Android Widget detect tap and double tap
body: <p>Okay, heres the problem. I have made a widget, and now need to detect tap and double tap on it, which when triggered should show a different view. For testing purposes I used logging, to see if it is working. Below is my code:</p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.GestureDetector;
  import android.view.GestureDetector.OnDoubleTapListener;
  import android.view.GestureDetector.OnGestureListener;
  import android.view.MotionEvent;
  import android.widget.Toast;
  
  /**
   * @Author Jan Zivkovic
   * 
   * NE DELA, OVERRIDA AMPAK NE DELA!
   */
  
  public class UpdateWidget extends Activity implements OnGestureListener{
  
      private GestureDetector gesture;
  
      public void onCreate(Bundle savedInstanceState)  
      {  
          super.onCreate(savedInstanceState);  
          //setContentView(R.layout.main);  
          Log.w("TEST", "started");
  
  
          gesture = new GestureDetector(this);  
  
          //set the on Double tap listener  
          gesture.setOnDoubleTapListener(new OnDoubleTapListener()  
          {  
              @Override  
              public boolean onDoubleTap(MotionEvent e)  
              {  
                  //set text color to green  
                  //tvTap.setTextColor(0xff00ff00);  
                  //print a confirmation message  
                  //tvTap.setText("The screen has been double tapped.");  
                  Log.w("TEST", "Double tap");
                  return false;  
              }  
  
              @Override  
              public boolean onDoubleTapEvent(MotionEvent e)  
              {  
                  //if the second tap hadn't been released and it's being moved  
                  if(e.getAction() == MotionEvent.ACTION_MOVE)  
                  {  
                      //set text to blue  
                      //tvTapEvent.setTextColor(0xff0000ff);  
                      //print a confirmation message and the position  
                      //tvTapEvent.setText("Double tap with movement. Position:\n"  
                      //        + "X:" + Float.toString(e.getRawX()) +  
                      //        "\nY: " + Float.toString(e.getRawY()));  
                  }  
                  else if(e.getAction() == MotionEvent.ACTION_UP)//user released the screen  
                  {  
                      //setContentView();  
                  }  
                  return false;  
              }  
  
              @Override  
              public boolean onSingleTapConfirmed(MotionEvent e)  
              {  
                  //set text color to red  
                  //tvTap.setTextColor(0xffff0000);  
                  //print a confirmation message and the tap position  
                  //tvTap.setText("Double tap failed. Please try again.");  
                  Log.w("TEST", "Single tap");
                  return false;  
              }  
          });  
      }
  
      @Override
      public boolean onDown(MotionEvent arg0) {
          // TODO Auto-generated method stub
          return false;
      }
  
      @Override
      public boolean onFling(MotionEvent arg0, MotionEvent arg1, float arg2,
              float arg3) {
          // TODO Auto-generated method stub
          return false;
      }
  
      @Override
      public void onLongPress(MotionEvent arg0) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
              float arg3) {
          // TODO Auto-generated method stub
          return false;
      }
  
      @Override
      public void onShowPress(MotionEvent arg0) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public boolean onSingleTapUp(MotionEvent arg0) {
          // TODO Auto-generated method stub
          return false;
      }
  
  }
  </code></pre>
  
  <p>Widget Provider class, onUpdate method (triggered every 5 minutes)</p>
  
  <pre><code>@Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
          for (int i = 0; i &lt; appWidgetIds.length; i++) {
              int appWidgetId = appWidgetIds[i];
              Intent updateIntent = new Intent(context, UpdateWidget.class);
              // Identifies the particular widget...
              updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
              updateIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              // Make the pending intent unique...
              updateIntent.setData(Uri.parse(updateIntent.toUri(Intent.URI_INTENT_SCHEME)));
              PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, updateIntent, 0);
  
  
              //context.startActivity(updateIntent);
  
              RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);//R.layout.widget_layout
              views.setTextViewText(R.id.subject1, "subject1 test");
              views.setOnClickPendingIntent(R.id.widget_layout, pendingIntent);
              appWidgetManager.updateAppWidget(appWidgetId, views);
              Log.w("Schedule", "Widget Updated = " + appWidgetId);
          }
          super.onUpdate(context, appWidgetManager, appWidgetIds);
      }
  </code></pre>
  
  <p>But heres what it gotten to be so far. Normaly when you tap or double tap on a widget, the phone vibrates. Using this, the phone doesen't vibrate anymore when tapped nor it prints anything in logcat. This problem is annoying me for the last couple of days. Hopefully someone else will know what I am doing wrong.</p>
  
  <p>EDIT: Forgot the most important thing. Im using Android 2.2 api level 8 (Froyo) And testing on Samsung Galaxy Ace VE with Android 2.3.6</p>