小编Dim*_*ski的帖子

从内部存储读取时,BitmapFactory.decodeStream 返回 null

我尝试从内部存储读取图像,当我解码FileInputStream, BufferedInputStreamFile 使用时,BitmapFactory我得到null以下结果:

//mImages is an ArrayList of image file names, "a.jpg","b.jpg", etc.
//This is inside my custom adapter for returing ImageViews from mImages:

public View getView(int position, View ..., ViewGroup...){
Context base_context = MyApplication.getAppContext();

String currentImageFilename = mImages.get(position); //say this is "cat.jpg"

//after this line f = "/data/user/0/mobile.foo.bar/files/cat.jpg"
File f = base_context.getFileStreamPath(currentImageFilename);

Boolean ex = f.exists(); //returns true, inserted only for debugging as no 
//exception was thrown when decoding the bitmap and …
Run Code Online (Sandbox Code Playgroud)

java android android-studio

3
推荐指数
1
解决办法
2697
查看次数

标签 统计

android ×1

android-studio ×1

java ×1