So snippets of the code I am using below. Every time I call the intent, it takes the picture, and I can see the photo successfully save because I have the image capture open on my mac. Except theres a problem... it saves it with a completely different file name than what I gave it. The data from the intent returned from startActivityForResult
also returns null. Has anyone else had this problem because my code is exactly as it should be and I even fixed it up to work/look more like the docs version of using the camera intent logic.
Code:
//Calling the intent
Uri outputFileUri = Uri.fromFile(createdMediaFile);
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(cameraIntent, RUN_CAMERA);
//onActivityResult()
File mediaStorageDir = new File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), appPhotoDirName
);
File photo = new File(mediaStorageDir.getPath() + File.separator +
"IMG_"+ timeStamp + ".jpg");
Log.d(TAG, photo.getAbsolutePath());
Log.d(TAG, "Does file exists: "+photo.exists());
observer = new FileObserver(photo.getAbsolutePath()) {
// set up a file observer to watch this directory on sd card
@Override
public void onEvent(int event, String file) {
Log.d(TAG, "File created [" + file + "]");
}
};
observer.startWatching();
The Glass camera does not support the EXTRA_OUTPUT
URI as an input into the activity. Instead, you should retrieve the image path using the EXTRA_PICTURE_FILE_PATH
extra from CameraManager
inside onActivityResult
.