私はOkHttpでWebサーバーの応答を取得しようとしています。 私の現在のminSdkVersion 15
。リソースの試用にはAPIレベル19(OkHttp)が必要です
私のコードは、私はラインtry (Response response = client.newCall(request).execute())
で警告を取得しています
@Override
protected String doInBackground(String... strings) {
GetDataFromUrl getData = new GetDataFromUrl();
String response = null;
try {
response = getData.run(URL);
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
そして
String run(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
です。
それは「Try-with-resources requires API level 19 (current min is 15)
を言っている。
を私は19に最小APIレベルを変更した場合、それが正常に動作しますことを知っている。しかし、私は15分のAPIレベルをサポートする必要があります。
は、任意の解決策はあります?
ありがとうございます。 :) – Sudarshan