Solution 1 :
in you’r question you say : ‘I’m trying to get a json via an url’
but in you’r code you wirte ‘StringRequest’ . i think if you change StringRequest to JsonRequest
problem solve.
Problem :
I’m trying to get a json via an url.
When I’m trying to access the url via my navigator, it’s work perfectly. But when I’m trying to access it via volley I got this error :
02-26 17:07:57.706 15056-15125/com.perso.simon.ulr_geoloc E/Volley: [5254] BasicNetwork.performRequest: Unexpected response code 403 for ...
02-26 17:07:57.716 15056-15125/com.perso.simon.ulr_geoloc E/Volley: [5254] BasicNetwork.performRequest: Unexpected response code 403 for ...
02-26 17:07:57.719 15056-15056/com.perso.simon.ulr_geoloc E/error: com.android.volley.AuthFailureError
I dont’t see where the error can be.
Here’s my code :
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
if(!isConnectedInternet(SplashScreenActivity.this)) {
AlertDialog.Builder builder = new AlertDialog.Builder(SplashScreenActivity.this);
builder.setPositiveButton(R.string.dialog_box_confirmation, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent i = new Intent(SplashScreenActivity.this, SplashScreenActivity.class);
startActivity(i);
}
});
builder.setMessage(R.string.dialog_box_text).setTitle(R.string.dialog_box_title);
AlertDialog dialog = builder.create();
dialog.show();
} else {
StringRequest requestBat = new StringRequest(urlBat, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.e("test", response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("error", error.toString());
}
});
requestBat.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
final RequestQueue requestQueue = Volley.newRequestQueue(SplashScreenActivity.this);
requestQueue.add(requestBat);
}
}
Comments
Comment posted by J.Doe
Unfortunately, problem not solved, the error is still the same. If you have other idea …
Comment posted by link
is this