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 ) 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..