I have the following class in which I'm trying to get some data from a specific url.:
public static class MyAsyncTask extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {}
@Override
protected String doInBackground(String... params) {
Log.d(TAG, "doInBackground: " + params[0]); //Works fine!
String response = "";
try {
URL url = new URL(params[0]);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
Log.d(TAG, "httpURLConnection.getResponseCode(): " + httpURLConnection.getResponseCode()); //Not triggered
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
@Override
protected void onPostExecute(String strings) {}
}
And this is how I'm creating the object:
String url = "http://...";
MyAsyncTask myAsyncTask = new MyAsyncTask();
myAsyncTask.execute(url);
So how can I log the response of httpURLConnection.getResponseCode()
?