简体   繁体   中英

Android App Crashing While Trying To Parse Json Object Using Volley

requestQueue = Volley.newRequestQueue(Home.this);

    JsonObjectRequest objectRequest = new JsonObjectRequest(com.android.volley.Request.Method.GET ,"http://www.omdbapi.com/?t=avengers",null,new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            try {
                String Title = response.getString("Title");
                String Year = response.getString("Year");
                String Released = response.getString("Released");
                String Genre = response.getString("Genre");
                String Metascore = response.getString("Metascore");
                String imdbRating = response.getString("imdbRating");
                String Poster = response.getString("Poster");

                moviesData = new String[]{Title, Year, Released, Genre, Metascore, imdbRating, Poster};
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
        }
    });

    requestQueue.add(objectRequest);

I am trying to fetch data from the site and store its content using json parsing and volley i was doing it with HttpUrlConnection and it was working fine when i tried to do it using volley I got stuck I don't know where I am going wrong or missing something don't know why App is crashing.

那是我自己的错,我用错误的方法编写了这段代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM