当用户点击十字标志时,如何从相机意图中删除照片。我开发了一个应用程序,其中刻度标志将照片保存到文件中,十字标志也将照片保存到文件中。如何删除该照片?请帮助me.Below是我到目前为止所做的代码。
public void Photo(View view) {
Intent intent = new Intent();
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException e) {
e.printStackTrace();
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intent, ACTIVITY_START_CAMERA_APP);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == ACTIVITY_START_CAMERA_APP && resultCode == RESULT_OK) {
saveJson();
}
else if(requestCode==ACTIVITY_START_CAMERA_APP&&resultCode==RESULT_CANCELED){
//delete
}
}
File createImageFile() throws IOException {
File storageDirectory = Environment.getExternalStoragePublicDirectory("GeoPark");
File myDir = new File(storageDirectory, FILENAME1);
if (myDir.isDirectory()) {
String[] children = myDir.list();
for (int i = 0; i < children.length; i++) {
new File(myDir, children[i]).delete();
}
}
else{
myDir.mkdirs();
}
File file = new File(myDir, timestamp);
return file;
}