title: Exception dispatching input event with DatePickerDialog on EditText Touch
body: <p>I am using <code>DatePickerDialog</code> in my <code>activity</code>. Now, for Updating data, I am using <code>EditDataActivity</code>, in which <code>EditText</code> contains <code>Date</code>. And When I touch on <code>EditText</code> I am getting error <strong><code>Exception dispatching input event</code></strong>.<br><br>
  Please help me to solve this issue.<br><br>
  <strong>DatePicker code :</strong></p>
  
  <pre><code>DatePickerDialog.OnDateSetListener StartDate = new DatePickerDialog.OnDateSetListener() {
  
          @Override
          public void onDateSet(DatePicker view, int year, int monthOfYear,
                  int dayOfMonth) {
              // TODO Auto-generated method stub
  
              myCalendar.set(Calendar.YEAR, year);
              myCalendar.set(Calendar.MONTH, monthOfYear);
              myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
  
              String myFormat = "dd-MM-yyyy";
              SimpleDateFormat sdf = new SimpleDateFormat(myFormat,
                      Locale.getDefault());
  
              ((EditText) etEIOStartDate)
                      .setText(sdf.format(myCalendar.getTime()));
          }
      };
  </code></pre>
  
  <p><strong>EditText touch event code :</strong></p>
  
  <pre><code>etEIOStartDate.setOnTouchListener(new View.OnTouchListener() {
  
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                  // TODO Auto-generated method stub
  
                  switch (event.getAction()) {
                  case MotionEvent.ACTION_DOWN:
                      new DatePickerDialog(getApplicationContext(), StartDate,
                              myCalendar.get(Calendar.YEAR), myCalendar
                                      .get(Calendar.MONTH), myCalendar
                                      .get(Calendar.DAY_OF_MONTH)).show();
                      break;
                  case MotionEvent.ACTION_UP:
                      break;
                  }
                  return true;
              }
          });
  </code></pre>
  
  <p>Here, <code>EditText</code> contains data on <code>onCreate()</code>. i.e. <em>15-09-2014</em></p>
  
  <p><br><Br>
  <strong>Logcat :</strong></p>
  
  <pre><code>04-20 18:56:05.421: E/InputEventReceiver(23397): Exception dispatching input event.
  04-20 18:56:05.421: E/MessageQueue-JNI(23397): Exception in MessageQueue callback: handleReceiveCallback
  04-20 18:56:05.431: E/MessageQueue-JNI(23397): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewRootImpl.setView(ViewRootImpl.java:707)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:453)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:351)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:171)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.app.Dialog.show(Dialog.java:282)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at com.band.seekersstop.EditInstantOpportunity$5.onTouch(EditInstantOpportunity.java:180)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.View.dispatchTouchEvent(View.java:7193)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2052)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1506)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.app.Activity.dispatchTouchEvent(Activity.java:2454)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2000)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.View.dispatchPointerEvent(View.java:7392)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3539)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3468)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4577)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4556)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4652)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:184)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.os.MessageQueue.nativePollOnce(Native Method)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.os.MessageQueue.next(MessageQueue.java:131)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.os.Looper.loop(Looper.java:132)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at android.app.ActivityThread.main(ActivityThread.java:5511)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at java.lang.reflect.Method.invokeNative(Native Method)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at java.lang.reflect.Method.invoke(Method.java:511)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
  04-20 18:56:05.431: E/MessageQueue-JNI(23397):  at dalvik.system.NativeStart.main(Native Method)
  04-20 18:56:05.431: W/dalvikvm(23397): threadid=1: thread exiting with uncaught exception (group=0x415f2390)
  04-20 18:56:05.441: E/AndroidRuntime(23397): FATAL EXCEPTION: main
  04-20 18:56:05.441: E/AndroidRuntime(23397): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewRootImpl.setView(ViewRootImpl.java:707)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:453)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:351)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:171)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.app.Dialog.show(Dialog.java:282)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at com.band.seekersstop.EditInstantOpportunity$5.onTouch(EditInstantOpportunity.java:180)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.View.dispatchTouchEvent(View.java:7193)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2187)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1888)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2052)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1506)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.app.Activity.dispatchTouchEvent(Activity.java:2454)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2000)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.View.dispatchPointerEvent(View.java:7392)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3539)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3468)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4577)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4556)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4652)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:184)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.os.MessageQueue.nativePollOnce(Native Method)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.os.MessageQueue.next(MessageQueue.java:131)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.os.Looper.loop(Looper.java:132)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at android.app.ActivityThread.main(ActivityThread.java:5511)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at java.lang.reflect.Method.invokeNative(Native Method)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at java.lang.reflect.Method.invoke(Method.java:511)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
  04-20 18:56:05.441: E/AndroidRuntime(23397):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>