Hi, using the example given by @Erel , I just add:
camEx.TakePicture in StopCamera like that :
Then add Camera1_PictureTaken like that :
When I compile, I got :
cameraexclass_takepicture (java line: 881)
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.CameraW.TakePicture()' on a null object reference
at b4a.example.cameraexclass._takepicture(cameraexclass.java:881)
at b4a.example.b4xmainpage._stopcamera(b4xmainpage.java:378)
at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:53)
at b4a.example.b4xmainpage.callSub(b4xmainpage.java:392)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1066)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:498)
at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:800)
at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:198)
at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:205)
at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:681)
at b4a.example.main._activity_create(main.java:366)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at b4a.example.main.afterFirstLayout(main.java:105)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7948)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Any clue, please?
Patrick
camEx.TakePicture in StopCamera like that :
B4X:
Private Sub StopCamera
Capturing = False
btnStartStop.Text = "Start"
' here Add camEx.TakePicture
camEx.TakePicture
pnlPreview.Visible = False
#if B4A
If camEx.IsInitialized Then
camEx.Release
End If
#Else If B4i
scanner.Stop
#end if
End Sub
Then add Camera1_PictureTaken like that :
B4X:
Sub Camera1_PictureTaken (Data() As Byte)
Dim filename As String = "1.jpg"
Dim dir As String = File.DirInternal
camEx.SavePictureToFile(Data, dir, filename)
camEx.StartPreview 'restart preview
End Sub
When I compile, I got :
cameraexclass_takepicture (java line: 881)
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.CameraW.TakePicture()' on a null object reference
at b4a.example.cameraexclass._takepicture(cameraexclass.java:881)
at b4a.example.b4xmainpage._stopcamera(b4xmainpage.java:378)
at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:53)
at b4a.example.b4xmainpage.callSub(b4xmainpage.java:392)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1066)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:498)
at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:800)
at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:198)
at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:205)
at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:681)
at b4a.example.main._activity_create(main.java:366)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at b4a.example.main.afterFirstLayout(main.java:105)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7948)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Any clue, please?
Patrick