Android Question Camera example only in landscape mode?

clooney48

Active Member
Licensed User
Longtime User
Can it be that the camera example of the camera library V2.20 works only in landscape mode? My app is in portrait mode so is there no chance to use it?

Thanks!
 

mc73

Well-Known Member
Licensed User
Longtime User
I think you may want to try the cameraEx lib, it fits to the chosen device's orientation. Still, from a trial I made on a specific device, I noticed that (again, it was a test only on one specific device), the photo was rotated 90 degrees. In a portrait based app I created, I deal with this, by adding another activity with its orientation set to landscape, in order to avoid such problems, without getting into fixes.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
I think you may want to try the cameraEx lib, it fits to the chosen device's orientation. Still, from a trial I made on a specific device, I noticed that (again, it was a test only on one specific device), the photo was rotated 90 degrees. In a portrait based app I created, I deal with this, by adding another activity with its orientation set to landscape, in order to avoid such problems, without getting into fixes.

I had the same issue but never thought about adding another activity set to landscape... My app will only support portrait mode (when on phone).
I resorted to EZcamera lib and let the default behaviour of the camera deal with all. It works fine - but I wanted landscape views - not portrait as clooney48 does.
 
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
I think you may want to try the cameraEx lib, it fits to the chosen device's orientation. Still, from a trial I made on a specific device, I noticed that (again, it was a test only on one specific device), the photo was rotated 90 degrees. In a portrait based app I created, I deal with this, by adding another activity with its orientation set to landscape, in order to avoid such problems, without getting into fixes.
Great! Works perfect for me. Thank´s a lot!
 
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
I encountered now a bit of a problem integrating both modules in my app. I added a new activity, the class modul, the view with panel1 and 2 buttons. When I start it, the code stops at the line
cam.Initialize2(Panel1, "camera", id)
of the "Public Sub Initialize" in the class modul:
B4X:
Public Sub Initialize (Panel1 As Panel, FrontCamera As Boolean, TargetModule As Object, EventName As String)
    target = TargetModule
    event = EventName
    Front = FrontCamera
    Dim id As Int
    id = FindCamera(Front).id
    If id = -1 Then
        Front = Not(Front) 'try different camera
        id = FindCamera(Front).id
        If id = -1 Then
            ToastMessageShow("No camera found.", True)
            Return
        End If
    End If
    cam.Initialize2(Panel1, "camera", id)
End Sub
I get the error msg:
java.lang.ClassCastException: android.widget.Button cannot be cast to android.view.SurfaceView
No idea what I did wrong.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Somehow I think that you named a button with the same name of the camera, "cam".
 
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
It is really funny! I stripped down my app so far that there are only the 2 modules of your camera example left. I even replaced my Main module by the camera example. But it does not run! It stoppes always at the same line ("cam.Initialize2(Panel1, "camera", id)"). Enclosed I send you the Zip File. Perhaps you can have a look at it. Would be interessting.
 

Attachments

  • Test Camera.zip
    257.3 KB · Views: 417
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Add to your layout an empty panel (for e.g. Panel2) then change your old line to this one:
B4X:
camEx.Initialize(Panel2, frontCamera, Me, "Camera1")
 
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
It is really funny! I stripped down my app so far that there are only the 2 modules of your camera example left. I even replaced my Main module by the camera example. But it does not run! It stoppes always at the same line ("cam.Initialize2(Panel1, "camera", id)"). Enclosed I send you the Zip File. Perhaps you can have a look at it. Would be interessting.
Add to your layout an empty panel (for e.g. Panel2) then change your old line to this one:
B4X:
camEx.Initialize(Panel2, frontCamera, Me, "Camera1")
Didn´work either. But by this hint I realized that the parent activity of the buttons was "Panel1". Normally it is "Activity". So I changed it to "Activity" and - it worked. Thanks a lot.
I have still a question concerning the jpg quality. I´ll open a new post.
 
Upvote 0
Top