无法解析queue.add(getRequest)

时间:2019-10-09 23:46:57

标签: java android-studio android-volley

Android Studio告诉我它无法解析我的queue.add(getRequest) 但是我的RequestQueue队列= Volley.newRequestQueue(this) 很好

我已经将所有内容导入到Manifest和所有必需的库中。

public class API extends AppCompatActivity {

private final String la = "https://api.darksky.net/forecast/private-key/37.8267,-122.4233";
private final String TAG = "WeatherFetcher";
RequestQueue queue = Volley.newRequestQueue(this);

// prepare the Request
JsonObjectRequest getRequest = new 
JsonObjectRequest(Request.Method.GET, la, 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");
            }
        }
);

// add it to the RequestQueue
//not resolved??
queue.add(getRequest);


}

0 个答案:

没有答案