I tried to do a simple GET request in an Android Code, I just copied the code from the official site of Volley but i get an error saying that : " Cannot resolve symbol "Method" ".
My code is this :
public void onReceive(final Context context, Intent intent) {
    // Instantiate the RequestQueue.
    RequestQueue queue = Volley.newRequestQueue(context);
    String url = ***** ; // my URL
    // Request a string response from the provided URL.
    StringRequest stringRequest = new StringRequest(DownloadManager.Request.Method.GET, url,
            new Response.Listener<String>() {  //the error is in THIS line
                @Override
                public void onResponse(String response) {
                    // Display the first 500 characters of the response string.
                    Toast.makeText(context, "Response is: " + response.substring(0,500), Toast.LENGTH_LONG).show();
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(context, "error", Toast.LENGTH_LONG).show();
        }
    });
// Add the request to the RequestQueue. queue.add(stringRequest);
For the imports, i have these lines (that i wrote manually):
 import com.android.volley.RequestQueue;
 import com.android.volley.Response;
 import com.android.volley.VolleyError;
 import com.android.volley.toolbox.StringRequest;
 import com.android.volley.toolbox.Volley;
I tried to include the line : " import com.android.volley.Request.Method;" but it doesn't change anything. I still got the same error
How can I fix this problem ?
You are using
DownloadManager.Request.Method.GET
instead of
 com.android.volley.Request.Method.GET
                        Your are using wrong class
Change
StringRequest stringRequest = new StringRequest(DownloadManager.Request.Method.GET, url,
to
StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.GET, url,
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With