Android Question CameraExClass and orientation

I've a similar issue like this post however I can't figure it out.

Our app is completly portrait. However a user can take a picture in every modus, it's a phone so landscape or portrait are options.

Using the code below results in allways an portrait preview and imagefile. Even if the picture is taken landscape.
B4X:
camEx.SavePictureToFile(DataFoto, File.DirInternal, psFotoFilename)

    oImageView.Gravity = Gravity.FILL
    oImageView.Bitmap =  camEx.LoadbitmapSample2(File.DirInternal,psFotoFilename,oImageView.Width,oImageView.Height,True)

When checking the exif data from the picture, the result i allways 90. Wheter we're holding the phone landscape or portrait
B4X:
Dim retValue As Int = 0
    Dim filepath As String
    Dim exif As ExifData
   

    filepath = dir & "/" & Filename
         
    exif.Initialize("", filepath)
         
    ' // Get orientation
    Dim w As Int = exif.getAttributeInt (exif.TAG_ORIENTATION, 0)
   
    If w = exif.ORIENTATION_NORMAL Then retValue = 0
    If w = exif.ORIENTATION_ROTATE_90  Then retValue = 90
    If w = exif.ORIENTATION_ROTATE_180  Then retValue = 180
    If w = exif.ORIENTATION_ROTATE_270  Then retValue = 270
   Log(retValue)
    Return retValue

Really need some help with this. Does the portrait mode has something to do with it?
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
I think I've found a workaround.
In Main we set the
B4X:
#SupportedOrientations: unspecified 'used to be portrait

In every view/activity that should not rotate we set, in the create, the following
B4X:
    Dim phone As Phone
    phone.SetScreenOrientation(1)

Then there is no rotation possible.
All other activities and views need to be checked and tested.
 
Upvote 0
Top