android图库过滤不存在图片,拍照后更新图库图库未显示所有图片Android...

我在onClick上使用onClick来捕获图像.

PictureCallback myPictureCallback_JPG = new PictureCallback() {

@Override

public void onPictureTaken(byte[] arg0, Camera arg1) {

FileOutputStream outStream = null;

try {

// Write to SD Card

outStream = new FileOutputStream(String.format("/sdcard/%d.jpg", System.currentTimeMillis()));

outStream.write(arg0);

outStream.close();

Toast.makeText(Photo.this, "Image Saved to SD Card", Toast.LENGTH_SHORT).show();

System.out.println();

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

camera.startPreview();

}};

图像保存在SD卡中.

然后用户单击“发送”按钮并打开布局,在“单击ImageView”上打开图像库并单击特定图像,将选择URI.

imageAttachPhoto = (ImageView)findViewById(R.id.imageViewPhotoOne);

imageAttachPhoto.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

Intent intent = new Intent();

intent.setType("image/*");

intent.setAction(Intent.ACTION_GET_CONTENT);

startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);

}

});

}

public void onActivityResult(int requestCode, int resultCode, Intent data) {

if (resultCode == RESULT_OK) {

if (requestCode == SELECT_PICTURE) {

Uri selectedImageUri = data.getData();

selectedImagePath = getPath(selectedImageUri);

System.out.println("Image Path : " + selectedImagePath);

imageAttachPhoto.setImageURI(selectedImageUri);

}

}

}

public String getPath(Uri uri) {

String[] projection = { MediaStore.Images.Media.DATA };

Cursor cursor = managedQuery(uri, projection, null, null, null);

int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);

cursor.moveToFirst();

return cursor.getString(column_index);

}

但是我无法查看在Gallery代码中捕捉的图像,但可以通过FileBrowser查看图像,当我在PC中打开SD卡时,我可以看到图像,然后Android也会在代码中显示图库中的图像.

让我知道问题是什么以及如何解决,期待您的回复.

谢谢.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值