Android:在内置库中显示图片

ged*_*agt 4 android image gallery

我试图在内置库中打开一张图片,但它不会显示出来.我记录了URI

06-08 15:53:02.232:D/URI(3231):file:///mnt/sdcard/com.jesper.indkoeb/nm-image.jpg

哪个是正确的地方

                @Override
                public void onClick(View v) {
                    Intent intent = new Intent();  
                    intent.setAction(android.content.Intent.ACTION_VIEW);  
                    File file = new File(uri.get(position));
                    Log.d("URI",uri.get(position));
                    intent.setDataAndType(Uri.fromFile(file), "image/*");  
                    context.startActivity(intent);

                }

            });
Run Code Online (Sandbox Code Playgroud)

Vip*_*hah 9

以下代码片段将帮助您.

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file:///mnt/sdcard/image/Apples.jpg"),"image/*");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)