我遇到相机意图问题。我在真实设备上测试我的应用程序 - 在Sony Xperia M4 Aqua和ST23 Miro上。我设法让应用程序在M4 Aqua上运行正常,但现在我在ST23上遇到了问题。每次我捕获图像时,它都会被发送到额外输出和手机的默认图像文件夹。我曾经在M4而不是ST23上遇到问题,但现在反过来了,我似乎无法找到解决方案。
相机意图:
public void callCamera()
{
picUri = null;
imageFile = null;
File dir = new File(absolutePath + appPath + imagePath);
if (dir.exists())
{
imageFile = new File(dir + "/" + imageName + imageFormat);
if (imageFile.exists()) {
boolean deleted = imageFile.delete();
if (deleted) {
Log.d("Image deleted", "Image has been deleted, because it already existed!");
}
}
}else{
boolean madeDirs = dir.mkdirs();
if (madeDirs){
Log.i("madeDirs", "Dirs were created");
imageFile = new File(dir + "/" + imageName + imageFormat);
}else{
Log.i("mkdirsFail", "Could not make dirs");
}
}
if (imageFile != null) {
try {
Uri uri = Uri.fromFile(imageFile);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("return-data", false);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, getResources().getString(R.string.toast_add_part_no_camera),
Toast.LENGTH_SHORT).show();
}
}
}
OnActivityResult()
if (resultCode != RESULT_CANCELED) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
picUri = Uri.fromFile(imageFile);
if (picUri != null)
performCrop(); // This is my crop function. Problem is not here.
}//else clause
}
正如我所说,这对我的M4 Aqua(6.0 MM)有效,但不适用于ST23(4.0.4 ICS)。我想解决这个问题,因为我不想最终在手机中充斥着不必要的图片。任何想法如何解决这个问题?