关于Base64转换成Bitmap的问题,每次转换Bitmap都是空

在网上查了一下这个方法可以把base64转换成Bitmap,
public static Bitmap stringToBitmap(String string) {
byte[] bytes = Base64.decode(string, Base64.DEFAULT);
Bitmap bitmap=BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
return bitmap;
}
可是我每次转换的bitmap值都是空,而我把参数string放在在线base64转图片里面是可以成功生成图片的,麻烦大家帮帮看看这个问题怎么解决?

你应该贴出来你的字符串string才好确定问题。
现在来看,你可以从以下几点去判断:
1. base64编码的string是否包含图片头,如(data:image/jpg;base64,)
2. 是否将string值传进了这个方法。
3. bytes 的数据是否正常。

方法没错。 看你转的是不是有问题。

public static Bitmap stringToBitmap(String string) {
    //这里加个打印
    Log.d("test", "stringToBitmap: "+string);
    byte[] bytes = Base64.decode(string, Base64.DEFAULT);
    Bitmap bitmap=BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
    return bitmap;
}
    然后看打印出来的string是不是和你放在线转图片的一样  
    可能你之前有什么操作或者特殊字符把string转码了