为什么甚至没有触发httpURLConnection.getResponseCode()?

时间:2019-03-11 15:52:30

标签: java android android-asynctask

我有以下课程,尝试从特定的URL中获取一些数据。

=IF(AND(M3="Closed",L3>K3),"Closed Late","Closed on time"),IF(AND(M3="Open",K3<TODAY()),"Overdue","OnTrack")

这就是我创建对象的方式:

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) {}
}

那我该如何记录String url = "http://..."; MyAsyncTask myAsyncTask = new MyAsyncTask(); myAsyncTask.execute(url); 的响应?

0 个答案:

没有答案