I'm using volley with callback interface. I'm send post request to server and server response 302 status code. How to set location in responsed header to variable string type? Then i want start new activity with full screen webview with this location.
this code in volley classes send requests:
public StringPostRequest(Context context, String url, Map<String, String> params) {
this.params = params;
this.url = url;
mQueue = Volley.newRequestQueue(context, new NukeSSLCerts());
}
public void getString(final VolleyCallback callback) {
StringRequest stringRequest = new StringRequest(Request.Method.POST, url ,
new Response.Listener<String>(){
@Override
public void onResponse(String response) {
req = response;
callback.onSuccess(req);
}
}
,new Response.ErrorListener(){
@Override
public void onErrorResponse(final VolleyError error){
final int status = error.networkResponse.statusCode;
// Handle 30x
if(HttpURLConnection.HTTP_MOVED_PERM == status || status == HttpURLConnection.HTTP_MOVED_TEMP || status == HttpURLConnection.HTTP_SEE_OTHER) {
final String location = error.networkResponse.headers.get("Location");
callback.onSuccess(location);
}
}
})
{
@Override
protected Map<String, String> getParams() throws AuthFailureError {
return params;
}
};
mQueue.add(stringRequest);
}
public interface VolleyCallback{
void onSuccess(String req);
}
In Main activity i'm creating Map for Post Request.
Map<String,String> params = new HashMap<>();
params.put("foo", "bar");
params.put("foo1", "bar1");
params.put("foo2", "bar2");
StringPostRequest getRedirectUrl = new StringPostRequest(this,url,params);
getRedirectUrl .getString(new StringPostRequest.VolleyCallback() {
@Override
public void onSuccess(String req) {
Log.d("reqInMainact", req);
RedirectUrl[0] = req;
}
});
return RedirectUrl[0];
But Location in response header not write to RedirectUrl[0] (( Help me please