Volley RequestQueue Unknown Class?

爷,独闯天下 提交于 2020-01-06 03:36:30

问题


I'm trying to implement a simple JsonObjectRequest with Volley. Everything seems to be working fine until I try to add the request to the queue, in which I get an "unknown class" error. I figure it has to be something simple, but I'm banging my head. What gives?

public void authGetRequest() {

RequestQueue queue = Volley.newRequestQueue(this);  // this = context

// prepare the Auth Get Request
JsonObjectRequest lastFMAuthRequest = new JsonObjectRequest(Request.Method.GET, lastFMKeyURL, null,
        new Response.Listener<JSONObject>()
        {
            @Override
            public void onResponse(JSONObject response) {
                // display response
                Log.d("Response", response.toString());
            }
        },
        new Response.ErrorListener()
        {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.d("Error.Response", error.toString());
            }
        }
);

// add it to the RequestQueue
queue.add(lastFMAuthRequest);

This is solved. After looking over the code, I figured out that the queue.add(lastFMAuthRequest); was in the wrong spot. Thx!


回答1:


1 ) add to grdle

dependencies { ... compile 'com.android.volley:volley:1.1.1' }

2) try clean/rebuild your project if it not work

go to File/invalidate caches /restart..



来源:https://stackoverflow.com/questions/25922825/volley-requestqueue-unknown-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!