Hi,
After verifying that the code of the starter service with the gps library and the ezcamera library worked well separately, we found that executing both causes some type of conflict that makes the application closes when executing this code :
The fact is that we have seen that the log show an error before even executing the activity_create:
If in the Activity_Resume we comment the lines marked with the red line, the previous error disappears and the code of the camera works again, but without the lines the service is not called and therefore the gps code does not work,
Could you tell us what the error might be?
this is the code that we use in the starter service:
thanks and best regards,
Héctor.
After verifying that the code of the starter service with the gps library and the ezcamera library worked well separately, we found that executing both causes some type of conflict that makes the application closes when executing this code :
B4X:
cam.TakePicture(dirFileCam,fileNameCam)
The fact is that we have seen that the log show an error before even executing the activity_create:
B4X:
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 339 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.BA.startActivityForResult(anywheresoftware.b4a.IOnActivityResult, android.content.Intent)' on a null object reference
at net.garstangs.ezcamera.EZcamera.TakePicture(EZcamera.java:65)
at b4a.example.main._camera(main.java:1153)
at b4a.example.main._panel2_click(main.java:1556)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:357)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5273)
at android.view.View$PerformClick.run(View.java:21315)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5659)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
java.lang.RuntimeException: java.net.SocketException: sendto failed: EBADF (Bad file descriptor)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.gps.GPS$2.onGpsStatusChanged(GPS.java:99)
at android.location.LocationManager$GpsStatusListenerTransport$1.handleMessage(LocationManager.java:1523)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5659)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
Could you tell us what the error might be?
this is the code that we use in the starter service:
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Public rp As RuntimePermissions
Public GPS1 As GPS
Private gpsStarted As Boolean
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
GPS1.Initialize("GPS")
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Public Sub StartGps
If gpsStarted = False Then
GPS1.Start(0, 0)
gpsStarted = True
End If
End Sub
Public Sub StopGps
If gpsStarted Then
GPS1.Stop
gpsStarted = False
End If
End Sub
Sub GPS_LocationChanged (Location1 As Location)
CallSub2(Main, "LocationChanged", Location1)
End Sub
Sub GPS_GpsStatus (Satellites As List)
CallSub2(Main, "GpsStatus", Satellites)
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
StopGps
End Sub
thanks and best regards,
Héctor.
Last edited: