EXIF orientation tag value always 0 for image taken with portrait camera app android

I also faced same issue in Samsung devices, later I implemented ExifInterface and solved successfully. In any mode images will be shot it will always store in portrait mode only, and while fetching too returning in portrait mode. below of code I used to achieve my goal, I implemented within back camera, not sure about … Read more

Rotating phone quickly 180 degrees, camera preview turns upside down

You can use OrientationEventListener to trigger recalculation of camera rotation. Add to your activity: private OrientationEventListener orientationListener = null; to onCreate(): orientationListener = new OrientationEventListener(this) { public void onOrientationChanged(int orientation) { setCameraDisplayOrientation(CustomCameraActivity.this, cameraId, camera); } }; to surfaceCreated(): orientationListener.enable(); to surfaceDestroyed(): orientationListener.disable(); Now, it almost works. To make setCameraDisplayOrientation() more robust, add check for camera … Read more

Controlling the camera to take pictures in portrait doesn’t rotate the final images

The problem is when I saved the image I didn’t do well. @Override public void onPictureTaken(byte[] data, Camera camera) { String timeStamp = new SimpleDateFormat( “yyyyMMdd_HHmmss”).format( new Date( )); output_file_name = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + File.separator + timeStamp + “.jpeg”; File pictureFile = new File(output_file_name); if (pictureFile.exists()) { pictureFile.delete(); } try { FileOutputStream fos = new FileOutputStream(pictureFile); … Read more

Restoring state of TextView after screen rotation?

If you want to force your TextView to save its state you must add freezesText attribute: <TextView … android:freezesText=”true” /> From documentation on freezesText : If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. By default this is … Read more

Force an Android activity to always use landscape mode

Looking at the AndroidManifest.xml (link), on line 9: <activity android:screenOrientation=”landscape” android:configChanges=”orientation|keyboardHidden” android:name=”VncCanvasActivity”> This line specifies the screenOrientation as landscape, but author goes further in overriding any screen orientation changes with configChanges=”orientation|keyboardHidden”. This points to a overridden function in VncCanvasActivity.java. If you look at VncCanvasActivity, on line 109 is the overrided function: @Override public void onConfigurationChanged(Configuration … Read more

Android: Temporarily disable orientation changes in an Activity

As explained by Chris in his self-answer, calling setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); and then setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); really works like charm… on real devices ! Don’t think that it’s broken when testing on the emulator, the ctrl+F11 shortcut ALWAYS change the screen orientation, without emulating sensors moves. EDIT: this was not the best possible answer. As explained in the comments, … Read more