我将sdk版本从27上传到28,但该应用无法正常运行。
我调试了应用程序,问题是Android Studio无法执行此操作,并跳转到返回值。
我在这里要做的是连接到http地址,并将其数据检索到列表中。
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(ConfigRed.INF_USERS_URL,
response -> {
//Calling method parseData to parse the json response
parseData(response);
},
error -> {
// Toast.makeText(ActividadPrincipal.this, "No se puede descargar usuarios, Obteniendo usuarios locales", Toast.LENGTH_LONG).show();
DatabaseHelper db;
db = new DatabaseHelper(getApplicationContext());
listUsuarios = db.getMuestreadoresConMuestrasCargadas();
if (listUsuarios.size() == 0) {
Toast.makeText(ActividadPrincipal.this, "No hay registros previos de usuarios. Conectate al laboratorio", Toast.LENGTH_LONG).show();
no_internet.setVisibility(View.VISIBLE);
} else {
adapter.setUsuarios(listUsuarios);
adapter.notifyDataSetChanged();
}
db.closeDB();
});
//Returning the request
return jsonArrayRequest;
我尝试了这种解决方案,但我仍在检索一个空列表
Volley Not making request on latest version of Android
我认为这是因为尽管有https,我仍尝试访问http网站,但我不知道该怎么办,因为使用sdk 27时,该应用程序可以正常运行,但由于Google Play政治原因,我需要使用sdk。 / p>
可以帮我吗?
答案 0 :(得分:1)
将此添加到Application标签中的清单中。那么它将顺利运行。
android:usesCleartextTraffic =“ true”
答案 1 :(得分:0)
您可以在本主题中找到解决方案
How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?
问题是因为使用了http,默认情况下它已被Android 9阻止
谢谢