I\'m trying to implement a login feature in my Android app using Lukencode\'s RestClient class. I have a class named UserFunctions
to retrieve JSONObject via RestCl
I won't expand on how you should do this, but only on why it happens. An AsyncTask, by definition, is asynchronous. This means that when you execute it, it does its job in parallel, in a different thread. So you can't expect it to be terminated right after execute()
has been called (else it would be called SyncTask, and wouldn't have any reason to exist).
See AsyncTask
as a toaster. When you start the toaster (execute the AsyncTask), it toasts your bread, but doesn't return the toasted bread immediately. It takes some time to toast it. While it's toasting your bread, you can do something else (and thus not freeze the UI thread completely). And when it has finished toasting your bread, it notifies you with a ding! that the bread is toasted. That's the same thing here. You should only start using json
(the toasted bread), when the AsyncTask notifies you that it has finished executing.