Now I look odd for replying to my own post twice, but I'd like to point out something missed in the documentation... In my code I have setButton because setPositiveButton and setNegativeButton are not recognized by the Eclipse plugin.
However setPositiveButton and setNegativeButton are still in the documentation at: http://developer.android.com/reference/android/app/AlertDialog.Builder.html ...and it's marked 1.5r2. So is it supported or not? And by the way, I bound the action below to a different key - Keycode_Call - and I got the dialog. So perhaps controlling the back button is out of our control? Thanks Rob On Fri, May 29, 2009 at 12:40 AM, Rob Franz <[email protected]> wrote: > Forgot to add this one thing from logcat: > E/WindowManager( 1804): Activity com.rmfdev.testApp has leaked window > com.android.internal.policy.impl.phonewindow$decorv...@431b5518 that was > originally added here > E/WindowManager( 1804): android.view.WindowLeaked: > Activity com.rmfdev.testApp has leaked window > com.android.internal.policy.impl.phonewindow$decorv...@431b5518 that was > originally added here > > Perhaps I'm not using the AlertDialog as it was designed to? > > On Fri, May 29, 2009 at 12:36 AM, Rob Franz <[email protected]> wrote: > >> Hi all, >> I've got something simple where I want to raise an AlertDialog after >> catching this keypress: >> >> @Override >> public boolean onKeyDown(int keyCode, KeyEvent event){ >> super.onKeyDown(keyCode, event); >> switch (keyCode){ >> >> case KeyEvent.KEYCODE_BACK: >> alertDialog= new >> AlertDialog.Builder(this).create(); >> alertDialog.setTitle("Option"); >> alertDialog.setMessage("Perform?"); >> alertDialog.setButton("Yes", new >> DialogInterface.OnClickListener >> () { >> public void onClick(DialogInterface dialog, >> int whichButton) { >> setResult(RESULT_OK); >> finish(); >> }}); >> alertDialog.setButton("No", new >> DialogInterface.OnClickListener >> () { >> public void onClick(DialogInterface dialog, >> int whichButton) { >> }}); >> alertDialog.show(); >> break; >> >> default: >> break; >> >> } >> return true; >> } >> >> The interesting thing here is that when you hit the back button, you >> *do* see the AlertDialog for a split second, but then you're back at >> the previous screen you were at. Almost as if the system is hellbent >> on sending the user back to the previous screen, regardless of what >> the developer has constructed around this event. >> >> Anyone else see this behavior? I'm using 1.5r2 here. Any help would >> be appreciated - I'm pretty sure I'm using this correctly and that >> this is a bug. >> >> Thanks >> Rob > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

