我有一些Android 7.0.0的问题.
我为我的应用程序使用volley库,除了Android 7.0之外它运行良好
这是我的代码的一部分;
String url_goster = "http://185.126.217.71/clog.php";
RequestQueue requestQueue;
StringRequest request= new StringRequest(Request.Method.POST, url_goster, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONObject veri_json;
try {
veri_json = new JSONObject(response);
JSONArray serial_no = veri_json.getJSONArray("Bilgiler");
for (int i = 0; i< serial_no.length(); i++){
JSONObject bilgis = serial_no.getJSONObject(i);
// JSON olarak verileri çekiyoruz
String GELEN_SERIAL = bilgis.getString("GELEN_SERIAL");
String TERMINAL_ADI = bilgis.getString("TERMINAL_ADI");
String SICAKLIK_T1 = bilgis.getString("SICAKLIK_T1");
String SICAKLIK_T2 = bilgis.getString("SICAKLIK_T2");
String SICAKLIK_T3 = bilgis.getString("SICAKLIK_T3");
String SON_DATA = bilgis.getString("SON_DATA");
String NEM_H1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试连接到这些地方之一并获取JSON数据:-
https://content.guardianapis.com/search?q=debate&tag=politics/politics&from-date=2014-01-01&api-key=test
https://content.guardianapis.com/search?q=debates&api-key=test
https://content.guardianapis.com/search?api-key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx
Run Code Online (Sandbox Code Playgroud)
我可以通过浏览器访问所有这三个,但是当我尝试通过Android应用访问它们时,出现以下错误:
NetworkSecurityConfig: No Network Security Config specified, using platform default
Error response code: 400
Run Code Online (Sandbox Code Playgroud)
我已将此添加到manifest.xml:-
<uses-permission android:name="android.permission.INTERNET"/>
Run Code Online (Sandbox Code Playgroud)
我还将此添加到manifest.xml:
android:networkSecurityConfig="@xml/network_security_config"
Run Code Online (Sandbox Code Playgroud)
并创建了res / xml / network_security_config.xml,其中包含:-
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config>
<domain includeSubdomains="true">content.guardianapis.com</domain>>
</domain-config>
Run Code Online (Sandbox Code Playgroud)
将错误更改为:
D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
Error response code: 400
Run Code Online (Sandbox Code Playgroud)
我知道它不见了:
<trust-anchors>
<certificates src="@raw/my_ca"/>
</trust-anchors>
Run Code Online (Sandbox Code Playgroud)
但我不知道证书在哪里或在什么地方,是否需要它。
不太确定发生了什么,将不胜感激。
另外:-我可以很好地连接并从此URL获取JSON:-
https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&eventtype=earthquake&orderby=time&minmag=6&limit=10
Run Code Online (Sandbox Code Playgroud)
我所得到的是:
No Network Security Config specified, using platform default
Run Code Online (Sandbox Code Playgroud)
购买不是错误400,而是获得200。因此,这让我觉得有些奇怪的事情正在发生,但不确定在哪里。