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 ?