squeeish squeeish - 1 year ago 207
Android Question

Get redirected URL from Picasso

I'm fetching my images using the following code:


returns a URL from my server, which will redirect to the actual image hosted on another server. Is there a way to catch the URL my server returns to Picasso? I know I can use a
, but that's all I know. I'm using OkHttp as well.

Answer Source

OkHttp allows you not to follow redirects automatically:

OkHttpClient client = new OkHttpClient();

You can read the response, get the redirect URL and then forward it manually to Picasso.


Interceptors are feasible as well:

OkHttpClient client = new OkHttpClient();
client.interceptors().add(new Interceptor() {
  public Response intercept(Chain chain) throws IOException {
    // process response here
    return response;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download