簡體   English   中英

Android上的畢加索不會加載此圖像Uri

[英]Picasso on Android does not load this image Uri

這張圖片Uri: http : //d3lca4hm3yw4jx.cloudfront.net/medialibrary/Empire+2/photos_thumb/Empire2.jpg未在畢加索加載

它在瀏覽器上加載良好。

Picasso.with(this)
    .load(Uri.parse(
        "http://d3lca4hm3yw4jx.cloudfront.net/medialibrary/Empire+2/photos_thumb/Empire2.jpg"))
    .fit()
    .error(android.R.drawable.stat_notify_error)
    .centerCrop()
    .into(iv, new Callback() {
      @Override
      public void onSuccess() {

      }

      @Override
      public void onError() {
        Log.d("error", "error");
      }
    });

設定:

OkHttpClient client = new OkHttpClient();
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
client.interceptors().add(logging);
Picasso.setSingletonInstance(new Picasso.Builder(this).downloader(new OkHttpDownloader(client))
    .memoryCache(new LruCache(50 * 1024 * 1024))
    .indicatorsEnabled(true)
    .loggingEnabled(true)
    .build());

使用的庫

compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.squareup.okhttp:okhttp:2.7.0'
compile 'com.squareup.okhttp:logging-interceptor:2.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'

整個資源可以在這里看到(僅一項活動)

https://github.com/slashrootv200/PicassoImageUri/blob/master/app/src/main/java/in/curium/picassotest/picassotest/MainActivity.java

編輯:

也添加了成功日志。 但是我得到了錯誤方法的回調。

03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: --> GET http://d3lca4hm3yw4jx.cloudfront.net/medialibrary/Empire+2/photos_thumb/Empire2.jpg HTTP/1.1
03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: Cache-Control: max-stale=2147483647, only-if-cached
03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: --> END GET
03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: <-- HTTP/1.1 504 Unsatisfiable Request (only-if-cached) (0ms)
03-20 00:59:11.112 27955-28089/in.curium.picassotest.picassotest D/OkHttp: <-- END HTTP (0-byte body)

從此處升級到Picasso版本2.6.0-SNAPSHOT可以解決此問題。 https://oss.sonatype.org/content/repositories/snapshots/com/squareup/picasso/picasso/2.6.0-SNAPSHOT/

您需要在清單文件中配置INTERNET權限。 沒有它,您的應用程序(因而也就是畢加索)將無法訪問互聯網。

例:

<manifest package="in.curium.picassotest.picassotest"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>

<application
  android:name=".App"
 ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM