相机X Imagecapture.TakePicture功能在Android上不起作用12
在这里,我正在尝试使用Camerax拍摄照片,它可以完美地使用Android 12设备,但是当使用Android 12设备时,它无法正常工作。
long x = System.currentTimeMillis();
String fileName = getExternalFilesDir(null) + "" + x + ".jpg";
File file = new File(fileName);
ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(file).build();
imageCapture.takePicture(outputFileOptions, executor, new ImageCapture.OnImageSavedCallback() {
@Override
public void onImageSaved(@NonNull ImageCapture.OutputFileResults outputFileResults) {
Log.e("xxxx", "yyy");
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Image Saved successfully", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onError(@NonNull ImageCaptureException error) {
error.printStackTrace();
}
});
我调试了代码,并在OnError函数中放了一个制动点,但没有被调用
Here i'm trying to take pictures using camerax , it is working with below android 12 devices perfectly but when use android 12 device it is not working.
long x = System.currentTimeMillis();
String fileName = getExternalFilesDir(null) + "" + x + ".jpg";
File file = new File(fileName);
ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(file).build();
imageCapture.takePicture(outputFileOptions, executor, new ImageCapture.OnImageSavedCallback() {
@Override
public void onImageSaved(@NonNull ImageCapture.OutputFileResults outputFileResults) {
Log.e("xxxx", "yyy");
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Image Saved successfully", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onError(@NonNull ImageCaptureException error) {
error.printStackTrace();
}
});
i debugged the code and put a brake-point in onError function , but it is not called
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论