Android Question Camera2 Problem at Android 5

Discussion in 'Android Questions' started by MarkusR, Sep 8, 2018.

Tags:
  1. MarkusR

    MarkusR Well-Known Member Licensed User

    hello,
    i will use the camera 2 but it gave me an error.
    my device have 5.0.2 API 21 19. Dezember 2014
    and it should work and i believe i tested it long ago and it worked.
    at my tablet device with android 6.0 it works.

    at os 5 the example said: Failed to open camera
    Code:
    Sub OpenCamera (front As Boolean)
        rp.CheckAndRequest(rp.PERMISSION_CAMERA)
        
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        
    If Result = False Then
            
    ToastMessageShow("No permission!"True)
            
    Return
        
    End If
     
        SetState(
    FalseFalse, VideoMode)
        
    Wait For (cam.OpenCamera(front)) Complete (TaskIndex As Int)
        
    If TaskIndex > 0 Then
            MyTaskIndex = TaskIndex 
    'hold this index. It will be required in later calls.
            Wait For(PrepareSurface) Complete (Success As Boolean)
        
    End If
        
    Log("Start success: " & Success)
        SetState(Success, 
    False, VideoMode)
        
    If Success = False Then
            
    ToastMessageShow("Failed to open camera"True)
        
    End If
        
    Log(cam.ActiveArraySize)
    End Sub
    the used example:
    https://www.b4x.com/android/forum/threads/camera2-still-images-and-videos.83920/#post-531669
     
    Last edited: Sep 8, 2018
  2. Erel

    Erel Administrator Staff Member Licensed User

    Does CameraEx (1) work with your device?

    Not all Android 5 devices properly support the relatively new Camera2 API. Check the logs and you will see a message about LEGACY support.
     
    MarkusR likes this.
  3. MarkusR

    MarkusR Well-Known Member Licensed User

    just found u updated this cameraex at 06/2018 :) my used source code was outdated.
    https://www.b4x.com/android/forum/t...e-camera-library-functionality.23801/#content

    yes there was LEGACY in log in camera2.

    this cameraex(1) example have all feature that i need.
    for any reason it ends the app after first test, i believe there is an issue with flash light and camera at my drevice.
    second test works. i will try using this 06/2018 version thank you erel.

    i had this error message in log.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice