AlertDialog OnCLickListener needs pressing back button to be active
<p>I've been trying to make it work for hours, but I can't find any suitable solution.</p>

<p>Here's the thing: I create an AlertDialog with 2 buttons, and set one OnClickListener on each of them.</p>

<p>The problem is that I have to press the back button to be able to "click" on one of the alert's buttons.</p>

<pre><code>        Context myActivity = getContext();
        OnClickListener posClickListener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Log.d("AlertBuilder", "positive button");
                dialog.cancel();
                dialog.dismiss();

                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.facebook.katana"));
                getContext().startActivity(intent);
            }
        };
        OnClickListener negClickListener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Log.d("AlertBuilder", "negative button");
                dialog.cancel();
                dialog.dismiss();
            }
        };

        AlertDialog.Builder builder = new AlertDialog.Builder(myActivity);
        builder.setMessage("Impossible de lancer l'application Facebook.\r\nVeuillez vérifier que vous avez installé et mis à jour l'application Facebook.")
                .setCancelable(false)
                .setNegativeButton("Retour", negClickListener)
                .setPositiveButton("Télécharger", posClickListener);
        AlertDialog alert = builder.create();
        alert.show();

        alert.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK)); // I tried this to simulate the back button action, but it doesn't work
</code></pre>

<p>Do you see anything bad in here?</p>

<p>/* =============  EDIT  ============= */</p>

<p>Ok, I think I've figured out what's going on.</p>

<p>In fact I try t create this dialog within a FbDialog, which extends the Dialog Class.</p>

<p>Maybe Android doesn't like Inception...</p>

<p>Any idea of how to sort this out?</p>
