日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

android访问重定向地址,如何从android中重定向url加载图像(示例代码)

發(fā)布時間:2025/3/8 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android访问重定向地址,如何从android中重定向url加载图像(示例代码) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

嗨,我正面臨這個問題

我從RESTCall獲取了一個URL

網(wǎng)址是http://hck.re/kWWxUI

但是當我在瀏覽器中檢查時,它會重定向到https://s3-ap-southeast-1.amazonaws.com/he-public-data/afreen2ac5a33.jpg

如何將此圖像加載到我的imageView中我已經(jīng)知道如何將畢加索的圖像加載到imageView中。任何幫助,將不勝感激

編輯:我已添加此代碼

OkHttpClient client = new OkHttpClient();

Picasso picasso = new Picasso.Builder(context)

.downloader(new OkHttp3Downloader(client))

.build();

picasso.load(music.getUrl())

.fit()

.into(holder.cover_image);

沒有運氣

答案

custom Picasso.Java

import android.content.Context;

import android.util.Log;

import com.jakewharton.picasso.OkHttp3Downloader;

import com.squareup.picasso.Picasso;

/**

* Created by Hrishikesh Kadam on 19/12/2017

*/

public class CustomPicasso {

private static String LOG_TAG = CustomPicasso.class.getSimpleName();

private static boolean hasCustomPicassoSingletonInstanceSet;

public static Picasso with(Context context) {

if (hasCustomPicassoSingletonInstanceSet)

return Picasso.with(context);

try {

Picasso.setSingletonInstance(null);

} catch (IllegalStateException e) {

Log.w(LOG_TAG, "-> Default singleton instance already present" +

" so CustomPicasso singleton cannot be set. Use CustomPicasso.getNewInstance() now.");

return Picasso.with(context);

}

Picasso picasso = new Picasso.Builder(context).

downloader(new OkHttp3Downloader(context))

.build();

Picasso.setSingletonInstance(picasso);

Log.w(LOG_TAG, "-> CustomPicasso singleton set to Picasso singleton." +

" In case if you need Picasso singleton in future then use Picasso.Builder()");

hasCustomPicassoSingletonInstanceSet = true;

return picasso;

}

public static Picasso getNewInstance(Context context) {

Log.w(LOG_TAG, "-> Do not forget to call customPicasso.shutdown()" +

" to avoid memory leak");

return new Picasso.Builder(context).

downloader(new OkHttp3Downloader(context))

.build();

}

}

build.gradle(模塊:app)

android {

...

}

dependencies {

...

compile 'com.squareup.picasso:picasso:2.5.2'

compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'

}

用法 -

CustomPicasso.with(context)

.load("http://hck.re/kWWxUI")

.into(imageView);

總結

以上是生活随笔為你收集整理的android访问重定向地址,如何从android中重定向url加载图像(示例代码)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。