Android Question Cameraex problem

Baris Karadeniz

Active Member
Licensed User
I used cameraex codes. Link is given below. In these codes camera is opened at the first layout (panel) and camera is initialized at the Activite_Resume.

https://www.b4x.com/android/forum/t...tends-the-camera-library-functionality.23801/

But in my app, there is a general view when app starts. There is a button at the main view for camera. When the camera button is pressed PanelCamera is opened and camera is initialized.

The difference; "InitializeCamera" is written in another place.

"camEx.Release" is written at the Activity_Pause sub like in original codes.

Camera works. No problem. But when the camera is opened and I close the app, failure occurs sometimes. Sometimes failure doesn't happen but when I opened app again, white screen comes in front of me so, I need to go to the main view and come back to the camera.

This problem happens I think as DonManfred said, "camEx.Release" is written still at the Activity_Pause sub although camerapanel is not initialized at the Activity_Create.

If I write "CamExRelease" to the sub which is used to back to the main menu, camera fails. There occurs misunderstanding view at the camera screen.

What should I do?

B4X:
Sub BtnCamera_Click
    PanelMain.Visible = False
    PanelCamera.Visible = True
    InitializeCamera
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    camEx.Release
End Sub

Sub BtnCameraBack_Click
    PanelCamera.Visible = False
    PanelMain.Visible = True
End Sub
 

JordiCP

Expert
Licensed User
Longtime User
Not tested, but I think that

In BtnCameraBack_Click, you should do a StopPreview.
In BtnCamera_Click, only call InitializeCamera if it is not initialized. Otherwise, call StartPReview.
In activity Pause, if you release your cam, to get to a consistent state when the app is resumed, you should also hide PanelCamera. This way, when it resumes, you will have the main screen again and not your panelCamera without a live preview on it.
 
Upvote 0
Top