private void load_data(final String Adress, final String Type) {
AsyncTask<Integer,Void,Void> task = new AsyncTask<Integer, Void, Void>() {
@Override
protected Void doInBackground(Integer... integers) {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url("http://"+Adress+"/get_data.php?&type="+Type).build();
try {
Response response = client.newCall(request).execute();
JSONArray array = new JSONArray(response.body().string());
for (int i=0;
i<array.length();
i++)
{
JSONObject object = array.getJSONObject(i);
DataPrognoz data = new DataPrognoz(
object.getInt("id"),
object.getInt("Name"),
object.getString("Age"),
);
data_list.add(data);
}
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
adapter.notifyDataSetChanged();
}
};
task.execute();
}
}
Выдает ошибки
https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted
Обсуждают сегодня