Showing AlertDialog when button is clicked problem
<p>I've got button in my Activity and I want to show AlertDialog when button is clicked:</p>

<pre><code>  @Override
public void onClick(View view) {
     case R.id.btnDetailedCall:
        final String[] phoneArray=ad.getPhone().split(" ");

        if(phoneArray.length&gt;1){

            AlertDialog.Builder builder=new AlertDialog.Builder(this);
            builder.setTitle("Title");
            builder.setSingleChoiceItems(phoneArray, -1, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    selectedPhone=phoneArray[which];
                }
            });
            AlertDialog dialog=builder.create();
            dialog.show();
  }
</code></pre>

<p>When I pass "this" to AlertDialog constructor code runs normally but dialog does not appear on the screen. I believe that "this" is not the right reference here, so I tried getBaseContext() and got <code>WindowManager$BadTockenException: Unable to add window -- tocken null is not for an application</code></p>

<p>Will appreciate any help, thanks.</p>
