I want to use AsyncTask to perform login with a server, and show a progress dialog before the connection ends.
Since there may not be response for the request, I need to set the timeout value for the AsyncTask. I found that when I simply use .execute()
, the program works fine but no timeout function is implemented. When I use .get(1000, TimeUnit.MILLISECONDS)
, the program just halts for 1 second and no progress dialog is shown.
Any one can tell me whether the task is executed when .get(1000, TimeUnit.MILLISECONDS)
is called? If yes, why there's no sign of execution; and if not, how can I implement this timeout function of the AsyncTask?