【发布时间】:2019-04-15 22:30:23
【问题描述】:
我在使用相机意图拍照时遇到了一些问题。在我和我朋友的一些设备中没问题,但不知何故它在三星设备中显示了一个小错误(大部分)。当我拍照时,捕捉到的图像的预览看起来很模糊。我已经在互联网上搜索了所有内容,但没有找到答案。
我唯一不明白的是,我的代码在我的设备测试中运行良好,顺便说一句,我使用的是谷歌代码,所以我很确定在所有设备上都可以。现在我很困惑,不知道该怎么办。
这是我的代码:
我的意图方法:
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
}
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(this,
"com.codelabs.refillmybottle.fileprovider",
photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, 1);
}
}
}
onActivityResult :
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
File imgFile = new File(mCurrentPhotoPath);
Log.d(TAG, "imgfile size : " + imgFile.length());
if(imgFile.exists()){
Uri bp = Uri.fromFile(imgFile);
Bitmap mybitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
Bitmap bitmap = decodeUri(bp,300);
chipdata++;
encodedeImageData[chipdata - 1] = getEncoded64ImageStringFromBitmap(bitmap);
checkChipData();
checkData();
}
}
decodeUri 是一种将 Uri 解码为位图并调整其大小的方法。
我真的希望任何人都可以回答我的错误,因为我的老板对我很生气,我很困惑 :D。谢谢。
【问题讨论】:
-
找到解决方案了吗?
标签: android android-intent camera blur