0

Unknown Host Exception Only in ONEPLUS 6T and Other Pie mobile在刷新三到四次后可以正常工作,然后获取数据,否则会出错

logcat-Access 拒绝查找属性“vendor.debug.egl.swapinterval”
尝试的解决方案:-

1.>

<network-security-config>
<base-config cleartextTrafficPermitted="true"/>
<debug-overrides>
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>

2.>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
android:usesCleartextTraffic="true"

3.>

    <?xml version="1.0" encoding="utf-8"?>
    <network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">http://www.sanjarcreation.com/</domain>
    </domain-config>
    </network-security-config>

public void parseHomeCategorydata(Context context){
        RequestQueue requestQ = Volley.newRequestQueue(context);
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, Const.Base_Url+"manage/api/p_category/all/?X-Api-Key="+Const.API_KEY+"&start=0&limit=100&field=shop_id&filter="+Const.Shop_id+"&parent=0" , null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                try {
                    JSONObject jsonObject = response.getJSONObject("data");
                    JSONArray jsonArray = jsonObject.getJSONArray("p_category");
                    homeCategoryRecModelArrayList = Parser.parseHomeCategoryList(jsonArray);
                    homeCategoryRecAdapter = new HomeCategoryRecAdapter(context , homeCategoryRecModelArrayList);
                    recyclerViewCategory.setAdapter(homeCategoryRecAdapter);
//                    parseSliderData(context);

                } catch (JSONException e) {

                    e.printStackTrace();
                }
            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        if(error.getMessage()==null){
                            Toast.makeText(context, "Failed to retrieve data", Toast.LENGTH_LONG).show();
                        }
                        else{
                            Toast.makeText(context, error.getMessage().toString(), Toast.LENGTH_LONG).show();
                        }

                    }
                }
        );
        requestQ.add(jsonObjectRequest);
    }

在此处输入图像描述

4

0 回答 0