BitmapFactory.decodeStream always returns null and skia decoder shows decode returned false

后端 未结 9 1270
北恋
北恋 2020-12-09 06:50

test image here: http://images.plurk.com/tn_4134189_bf54fe8e270ce41240d534b5133884ee.gif

I\'ve tried several solutions found on the internet but there is no working

9条回答
  •  囚心锁ツ
    2020-12-09 07:32

    I tried all the solutions but did not solved my problem. After some tests, the problem of skia decoder failing happened a lot when the internet connection is not stable. For me, forcing to redownload the image solved the problem.

    The problem also presented more when the image is of large size.

    Using a loop will required me at most 2 retries and the image will be downloaded correctly.

    Bitmap bmp = null;
    int retries = 0;
    while(bmp == null){
        if (retries == 2){
            break;
        }
        bmp = GetBmpFromURL(String imageURL);
        Log.d(TAG,"Retry...");
        retries++;
    }
    

提交回复
热议问题