I was looking for an answer, but no one really answers, because there is no point in using the async task for it; in Android api 11 or higher, it will force the code to execute network requests on the main thread, so I need to perform an asynchronous task ... So, the question is, can I wait for the asynchronization to complete before continuing, I need data for the next method and so on .d.
Here is my code:
public JSONObject getJSONFromUrl(String url) { this.url = url; new loadURL().execute(); // Do this when ASYNC HAS FINISHED return jObj; } class loadURL extends AsyncTask <Void, Void, Void> { protected void onPreExecute() { } protected Void doInBackground(Void... unused) { //do stuff in background return (null); } }
}
Any questions for awnser just leave a comment. Thanks for the help.
source share