I am having issues with the camera intent. I am testing my app on real devices - on a Sony Xperia M4 Aqua and ST23 Miro. I managed to get the app working ok on the M4 Aqua, but now I have an issue on the ST23. Every time I capture an Image it is being sent to both the extra output, and the phone's default image folder. I used to have the issue on the M4 and not the ST23, but now it's the other way around, and I cant seem to find the solution.
The camera intent:
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
}
As I said, this works fine on my M4 Aqua (6.0 MM), but not on the ST23(4.0.4 ICS). I want to fix this, because i don't want to end up flooding the phone with unnecessary pictures in the gallery. Any ideas how to fix this?