Android Question error with CameraEx

cncncn

Member
Licensed User
Longtime User
Hi

I am beginner with Basic4Android but i want to progress. I work on application torch and more options.
But i have error when I press my button flash. This is my project.

B4X:
#Region  Project Attributes
    #ApplicationLabel: Application LED
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: false
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private frontCamera As Boolean = False
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim btntorche As Button
    Private Panel1 As Panel
    Private camEx As CameraExClass
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("accueil")
    'Msgbox("Bienvenu dans l'application Led", "")
End Sub

Sub Activity_Resume
    InitializeCamera
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    camEx.Release
End Sub
Sub btntorche_click
    Log("btntorche")
    Dim F() As Float = camEx.GetFocusDistances
    Log(F(0) & ", " & F(1) & ", " & F(2))
    Dim flashModes As List = camEx.GetSupportedFlashModes
    If flashModes.IsInitialized = False Then
        ToastMessageShow("Flash non supporté.", False)
        Return
    End If
    Dim flash As String = flashModes.Get((flashModes.IndexOf(camEx.GetFlashMode) + 1) Mod flashModes.Size)
    camEx.SetFlashMode(flash)
    ToastMessageShow(flash, False)
    camEx.CommitParameters

End Sub
Private Sub InitializeCamera
    camEx.Initialize(Panel1, frontCamera, Me, "Camera1")
    frontCamera = camEx.Front
   
End Sub
Sub Camera1_PictureTaken (Data() As Byte)
    Dim filename As String = "1.jpg"
    Dim dir As String = File.DirRootExternal
   
    camEx.SavePictureToFile(Data, dir, filename)
    camEx.StartPreview 'restart preview
   
    'send a broadcast intent to the media scanner to force it to scan the saved file.
    Dim Phone As Phone
    Dim i As Intent
    i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", _
        "file://" & File.Combine(dir, filename))
    Phone.SendBroadcastIntent(i)
    ToastMessageShow("Picture saved." & CRLF  & "File size: " & File.Size(dir, filename), True)
End Sub
Sub Camera1_Ready (Success As Boolean)
    If Success Then
        camEx.SetJpegQuality(90)
        camEx.CommitParameters
        camEx.StartPreview
        Log(camEx.GetPreviewSize)
    Else
        ToastMessageShow("Cannot open camera.", True)
    End If
End Sub


Thank
 

cncncn

Member
Licensed User
Longtime User
LogCat connected to: ABFAE292E0135491
--------- beginning of /dev/log/system


--------- beginning of /dev/log/main


** Activity (main) Create, isFirst = true **


** Activity (main) Resume **


btntorche


Error occurred on line: 260 (cameraexclass)
java.lang.NoSuchMethodException: getFocusDistances [class [F]


at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getDeclaredMethod(Class.java:685)
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:214)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod4(Reflection.java:857)
at b4a.appliLed.cameraexclass._getfocusdistances(cameraexclass.java:95)
at b4a.appliLed.main._btntorche_click(main.java:381)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:66)
at android.view.View.performClick(View.java:4091)
at android.view.View$PerformClick.run(View.java:17072)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0
Top