[英]Delete picture taken from camera
我正在嘗試刪除該應用程序剛剛拍攝的照片,因為我已經將其保存到了tmp文件夾中以供以后使用,並且我不希望該照片顯示在圖庫中。 問題是我不知道該怎么做,我嘗試了一堆東西,但現在陷入困境。 這是我的最新代碼( onActivityResult
的數據為null,我不知道為什么):
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == TAKE_PIC && resultCode == RESULT_OK) {
Uri path = data.getData();
new File(path.getPath()).delete();
Toast.makeText(this, "Picture taken!", Toast.LENGTH_LONG).show();
}
}
public void onButtonClick(View view) {
CheckBox ckBox = (CheckBox) findViewById(R.id.cmark_picture);
if (ckBox.isChecked())
takePicture(view);
}
private void takePicture(View view) {
tmpImg = new File(TMPDIR, "tmp.png");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpImg));
startActivityForResult(intent, TAKE_PIC);
}
完成目標后,使用以下代碼刪除捕獲的圖像
File casted_image = new File("path of image");
if (casted_image.exists()) {
casted_image.delete();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.