开发者

How to Send Message From AlertDialog to Activity

I'm trying to ask the user if he wants to retry a login p开发者_如何转开发rocess if the initial one has failed. I do this using an AlertDialog. The problem is i'm going around in a circle. Let me explain: I have the login method named Login which I call from the main activity. If this fails, I open an AlertDialog. The response from AlertDialog comes on the main thread. How do I make the AlertDialog dissapear before I call Login again?

Now I have something like this onCreate->Login->AlertDialog->ResponseHandler->Login. If I do this, the AlertDialog will never close because everything happens on the same thread.

Is there a way to send the response from the AlertDialog to the activity in a asynchronous way?


You can declare a Handler object as an anonymous inner class in your activity and on its reference call the sendEmptyMessage(0). in the handlerMessage() of the handler instance just dismiss the AlertDialog.

Here is a tutorial link which will help you more http://www.tutorialforandroid.com/2009/01/using-handler-in-android.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜