【发布时间】:2015-02-25 11:18:03
【问题描述】:
在这里,我尝试从我在该程序的活动之前保存的文件夹中打开照片,但在这里我仍然面临异常。
ImageView img = null;
Bitmap bmp = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.photoeffect_1);
Intent i = this.getIntent();
String s = i.getStringExtra("second");
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
bmp = BitmapFactory.decodeFile("/sdcard/GWonderPhoto/"+s+".jpg");
img = (ImageView) findViewById(R.id.imageView1);
img.setImageBitmap(bmp);
// TODO Auto-generated method stub
}
例外:
'02-25 17:07:07.543: E/BitmapFactory(24805): 无法解码流: java.io.FileNotFoundException:/sdcard/GWonderPhoto/1424905623242.jpg: 打开失败:ENOENT(没有这样的文件或目录)'
【问题讨论】:
-
检查图片路径!
-
日志显示“(没有这样的文件或目录)”。 @Rami 是对的!检查路径
-
尝试将
decodeFile("/sdcard/GWonderPhoto/"+s+".jpg");更改为:decodeFile("file://" +"/sdcard/GWonderPhoto/"+s+".jpg");或更改为:decodeFile("content://sdcard/GWonderPhoto/"+s+".jpg"); -
@Josef 仍然无法工作
-
这里是你的解决方案:stackoverflow.com/questions/15939733/…