title: Customized popup window leads to leaked window.
body: <p>I have the following code for displaying a customized popup, however executing the same leads to a leaked window error, I am not able to determine how to resolve it. Following is my code: </p>
  
  <pre><code>    public void Reminder() {
      dDialog = new Dialog(Farrier.this);
      dDialog.setContentView(R.layout.farrierpop2);
      dDialog.setTitle("Reminder");
      dDialog.setCancelable(true);
      final Button pop1 = (Button) dDialog.findViewById(R.id.Btn1);
      pop1.setOnClickListener(new OnClickListener() {
          public void onClick(View v) {
              Intent intent = new Intent(Intent.ACTION_EDIT);
              intent.setType("vnd.android.cursor.item/event");
              intent.putExtra("title", IDB);
              intent.putExtra("description", "Farrier Service");
              intent.putExtra("beginTime", "eventStartInMillis");
              intent.putExtra("endTime", "eventEndInMillis");
              startActivity(intent);
              finish();
          }
      });
      Button pop2 = (Button) dDialog.findViewById(R.id.Btn2);
      pop2.setOnClickListener(new OnClickListener() {
          public void onClick(View v) {
              // dDialog.dismiss();
              Intent ourpartner = new Intent(Farrier.this, FarrierSch.class);
              startActivity(ourpartner);
              finish();
          }
      });
      dDialog.show();
  }
  </code></pre>
  
  <p>The Stack Trace is: </p>
  
  <pre><code>*07-01 11:30:18.646: E/WindowManager(407): Activity com.gallops.Farrier has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@45fe7468 that was originally added here
  07-01 11:30:18.646: E/WindowManager(407): android.view.WindowLeaked: Activity com.gallops.Farrier has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@45fe7468 that was originally added here
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.ViewRoot.&lt;init&gt;(ViewRoot.java:227)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.Window$LocalWindowManager.addView(Window.java:424)
  07-01 11:30:18.646: E/WindowManager(407):   at android.app.Dialog.show(Dialog.java:239)
  07-01 11:30:18.646: E/WindowManager(407):   at com.gallops.Farrier.Reminder(Farrier.java:185)
  07-01 11:30:18.646: E/WindowManager(407):   at com.gallops.Farrier$2.onClick(Farrier.java:915)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.View.performClick(View.java:2364)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.View.onTouchEvent(View.java:4179)
  07-01 11:30:18.646: E/WindowManager(407):   at android.widget.TextView.onTouchEvent(TextView.java:6541)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.View.dispatchTouchEvent(View.java:3709)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  07-01 11:30:18.646: E/WindowManager(407):   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
  07-01 11:30:18.646: E/WindowManager(407):   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
  07-01 11:30:18.646: E/WindowManager(407):   at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
  07-01 11:30:18.646: E/WindowManager(407):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
  07-01 11:30:18.646: E/WindowManager(407):   at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
  07-01 11:30:18.646: E/WindowManager(407):   at android.os.Handler.dispatchMessage(Handler.java:99)
  07-01 11:30:18.646: E/WindowManager(407):   at android.os.Looper.loop(Looper.java:123)
  07-01 11:30:18.646: E/WindowManager(407):   at android.app.ActivityThread.main(ActivityThread.java:4363)
  07-01 11:30:18.646: E/WindowManager(407):   at java.lang.reflect.Method.invokeNative(Native Method)
  07-01 11:30:18.646: E/WindowManager(407):   at java.lang.reflect.Method.invoke(Method.java:521)
  07-01 11:30:18.646: E/WindowManager(407):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  07-01 11:30:18.646: E/WindowManager(407):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  07-01 11:30:18.646: E/WindowManager(407):   at dalvik.system.NativeStart.main(Native Method)*
  </code></pre>