如何在捕获图像后删除确认显示('保存'以及'丢弃'按钮显示)?
我想在不更改应用程序功能的情况下删除第二步:在startActivityForResult
函数之后转到previewCapturedImage()
函数。
这是我的代码:
public class MainActivity extends Activity {
private static final int CAMERA_CAPTURE_IMAGE_REQUEST_CODE = 100;
public static final int MEDIA_TYPE_IMAGE = 1;
private static final String IMAGE_DIRECTORY_NAME = "OpenCV Demo";
private Uri fileUri;
private ImageView imgPreview;
private Button btnCapturePicture;
private FrameLayout frameLayout;
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_8, this, mOpenCVCallBack))
{
Log.e("TEST", "Cannot connect to OpenCV Manager");
}
setContentView(R.layout.activity_main);
}
private void captureImage() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
// start the image capture Intent
startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if the result is capturing Image
if (requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
// successfully captured the image
// display it in image view
previewCapturedImage();
} else if (resultCode == RESULT_CANCELED) {
// user cancelled Image capture
Toast.makeText(getApplicationContext(),
"User cancelled image capture", Toast.LENGTH_SHORT)
.show();
} else {
// failed to capture image
Toast.makeText(getApplicationContext(),
"Sorry! Failed to capture image", Toast.LENGTH_SHORT)
.show();
}
}
}
private void previewCapturedImage() {
//TODO something
}
答案 0 :(得分:5)
如何在捕获图像后删除确认显示('保存'和'丢弃'按钮显示)?
你做不到。那不是你的应用程序。这来自用户选择的处理ACTION_IMAGE_CAPTURE
的活动。该活动来自其他开发人员的应用程序,欢迎开发人员做任何开发人员想要的事情。如果您希望将照片委托给第三方应用程序,那么您将不得不忍受该第三方应用程序希望拍摄该照片。