Collect compass direction and camera tilt at time of photo capture

I'm trying to collect the compass direction and the tilt of the phone at the time a picture is taken. Of course, I'm not sure of an easy way to do this. My current camera implementation uses:

    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

        File file = new File(Environment.getExternalStorageDirectory(), "test.jpg");
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
        outputFileUri = Uri.fromFile(file);

        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);  

Remember, the tilt and direction must be collected at the time of the photo snap. I can't seem to find anything in the exif data or a built in feature when calling the camera intent.



  • The only way I can think of is using takePicture and capturing the compass, tilt and whatever other information you want in a ShutterCallback. That way you'll be asking for that info as soon as the user hits the shutter button, not some arbitrary amount of time which elapses between the shutter and the triggering of a PictureCallback.