我是新来的android和我遇到这个错误,当我尝试使用decodefile()
。无法解码Android中的流java.io.FileNotFoundException?
下面是代码
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if ((requestCode == PICK_FROM_GALLERY) && (resultCode == RESULT_OK) && (data != null)){
selectedImageUri = data.getData();
Log.e("Path1", ""+selectedImageUri);
path1 = selectedImageUri.getPath();
file = new File(path1);
path =file.getAbsolutePath();
Log.e("Path2", file.getAbsolutePath());
mImageView.setImageURI(selectedImageUri);
}}
protected void badButtonPressed() {
final long startTime = SystemClock.uptimeMillis();
BitmapFactory.Options options = new BitmapFactory.Options();
// Part 1: Decode image
>> Bitmap unscaledBitmap = BitmapFactory.decodeFile(path, options);
imageHeight = options.outHeight;
imageWidth = options.outWidth;
Log.e("w", ""+imageWidth);
Log.e("h", ""+imageHeight);
请告诉我,我的错误。
请张贴完整堆栈跟踪。 –
欢迎来到Stack Overflow。我编辑了你的帖子来解决一些英文问题。我还用两个星号加粗了函数名称。 我看不到你提到的错误。请修改您的帖子并向我们显示错误(使用>在该行的开头标记它)。 –
@RohutGupta你为什么加粗了函数名?当代码格式化已经存在? – EJP