In my android application, I am using a custom dialog. When I try to show the dialog, it causes an error. I don\'t know what I am doing wrong, and I am really confused.
<
First of all, you're using that method wrong. The point of the createDialog
method is to, well, create the dialog and then return it. You're showing the dialog within the method, then not returning it at all, which defeats the purpose of overriding that method at all. You really should just have your own method that creates and displays your dialog.
Second of all, as AVD posted in the comments to your question, that method of displaying dialogs is deprecated for apps targeting an API for Honeycomb (11) or later.
Your problem, however, is that you're using the Application Context
(getApplicationContext()
) object to display a dialog that should belong to your Activity
. You should pass in this
instead to use the Activity
context and that will fix your error.