I have an app that user submit the log in form , when it sent the data to server and create a connection for its account.
In this connection i have an integer field named as state.
the state value is : 1 for connecting, 2 for connected and 0 for failed.
I want to show a dialog to user show is Connecting ...
and then check the state of connection if its return 0 or 2 dismiss the dialog and show the related message else if it doesn't change after 15 sec dismiss dialog and change the state to 0 !
How can i do this logic ?