Why does BitmapFactory.decodeByteArray return null?

后端 未结 7 857
失恋的感觉
失恋的感觉 2020-11-28 16:02

It\'s the simple code and instead of getting result to set the Bitmap, I get null. Can anyone tell me where I am making a mistake?

String test = \"test\";
by         


        
7条回答
  •  -上瘾入骨i
    2020-11-28 16:22

    Because the bytes in "test".getBytes() doesn't represent a valid bitmap.

    You need to create a byte-array which actually contains an encoded bitmap, not just some "random bytes" corresponding to the representation of a string.

提交回复
热议问题