Problem with AlertDialog
<p>I'm having problem with creating AlertDialog. </p>

<p>I would like that AlertDialog appears when i click on one button, so i put all code for creating dialog in that button listener...the same code works outside that listener but inside listener doesn't work...it doesn't call any errors but when i start emulator written is something about this: "Aplication has terminated unexpectedly"....</p>

<p>This is my code for that:</p>

<pre><code>btsenddata.setOnClickListener(new Button.OnClickListener() { 

      public void onClick (View v){ 

        AlertDialog.Builder alt_bld = new AlertDialog.Builder(getApplicationContext() ); // I've tried with "activity1.this" instead "getApplicationContext()" but it is the same result
        alt_bld.setMessage("Do you want to close this window ?")
        .setCancelable(false)
        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        // Action for 'Yes' Button
        }
        })
        .setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        // &amp;nbsp;Action for 'NO' Button
        dialog.cancel();
        }
        });
        AlertDialog alert = alt_bld.create();
        // Title for AlertDialog
        alert.setTitle("Title");
        // Icon for AlertDialog
        alert.setIcon(R.drawable.icon);
        alert.show();
      }});
}
</code></pre>

<p>.... i've heard that method getApplicationContext() is creating some problems but i've tried replace it with activity.this and it doesn't work anyway...
If anyone knows the reason for this or more about alertdialogs pleade answer.
Thanks.</p>
