gpt4 book ai didi

Java Android 关闭相机

转载 作者:行者123 更新时间:2023-12-01 12:42:49 24 4
gpt4 key购买 nike

我使用以下代码行打开相机:

public void TakePhoto(){
Intent camIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camIntent,0);

}

protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
CordovaPlugin callback = this.activityResultCallback;
if (callback != null) {
callback.onActivityResult(requestCode, resultCode, intent);
}

if (requestCode==0){
Bitmap camImage = (Bitmap) intent.getExtras().get("data");
ImageView ivPhoto = null;
//ivPhoto.setImageBitmap(camImage);
}
}

在 ActivityResult 中我想关闭相机,我该怎么做?

最佳答案

尝试这样的事情:

File tempFolder = new File(Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/myfolder");
tempFolder.mkdir();
file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/myfolder",
String.valueOf(System.currentTimeMillis()) + ".jpg");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intent, TAKE_PICTURE);

关于Java Android 关闭相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24938148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com