该网址不适用于api 15& 16

时间:2018-02-16 17:00:24

标签: android android-studio url

url不适用于模拟器api 15和16,它适用于api> 17

Inside OnCreate

private void ShowPosts(String url)
    {
        rv_posts = (RecyclerView)findViewById(R.id.rv_posts);
        rv_posts.setVisibility(View.GONE);
        requestQueue = Volley.newRequestQueue(Messages.this);
        JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, url.replace(" ", "%20"), null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                try {
                    for(int x = 0 ; x < response.length() ; x++)
                    {
                        item_messages.add(new Item_Messages(response.getJSONObject(x).getString("id"),response.getJSONObject(x).getString("message"),response.getJSONObject(x).getString("photo"),response.getJSONObject(x).getString("date"),response.getJSONObject(x).getString("type")));
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }
                rv_posts.setLayoutManager(new LinearLayoutManager(Messages.this,LinearLayoutManager.VERTICAL,false));
                adapter_messages = new Adapter_Messages(Messages.this, item_messages);
                rv_posts.setAdapter(adapter_messages);
                rv_posts.setVisibility(View.VISIBLE);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(Messages.this, "Error Try Again", Toast.LENGTH_LONG).show();
            }
        });
        requestQueue.add(jsonArrayRequest);
}

ShowPosts

join

我该如何解决这个问题?

0 个答案:

没有答案