Hi all:
I have a working app with the login logic in the Main activity, working fine.
Now, I want to move the non ui related code to services (mainly the db code and a part where I have to read images from the phone to show them in a Listview)
When I move the code to a service and call it with CallDelayedSub I got the error:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I've found this problem in a similar thread, but I got DBResults and DBCommand types in my code.
https://www.b4x.com/android/forum/threads/jrdc2-dbcommand-error.78208/
Activity:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Service DB:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Thanks in advance
			
			I have a working app with the login logic in the Main activity, working fine.
Now, I want to move the non ui related code to services (mainly the db code and a part where I have to read images from the phone to show them in a Listview)
When I move the code to a service and call it with CallDelayedSub I got the error:
			
				B4X:
			
		
		
		<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 </title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /rdc. Reason:
<pre>    java.lang.ClassNotFoundException: b4j.example.db$_dbcommand</pre></p>
<hr /><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.3.z-SNAPSHOT</a><hr/>
</body>
</html>I've found this problem in a similar thread, but I got DBResults and DBCommand types in my code.
https://www.b4x.com/android/forum/threads/jrdc2-dbcommand-error.78208/
Activity:
			
				B4X:
			
		
		
		Sub BtLogin_Click
    If ETUsuario.Text = "" Then
        ToastMessageShow("Debe introducir un usuario", False)
    Else If    ETPassword.Text = "" Then
        ToastMessageShow("Debe introducir una contraseña", False)
    Else
        ProgressDialogShow("Comprobando credenciales...")
        CallSubDelayed3("DB", "Login", ETUsuario.Text, ETPassword.Text)
    End If
End SubService DB:
			
				B4X:
			
		
		
		#Region  Service Attributes
    #StartAtBoot: False
  
#End Region
Sub Process_Globals
    Dim reqManager As DBRequestManager
    Type DBResult (Tag As Object, Columns As Map, Rows As List)
    Type DBCommand (Name As String, Parameters() As Object)
End Sub
Sub Service_Create
    reqManager.Initialize(Me, "http://semisevilla.synology.me:8090/rdc")
End Sub
Sub Service_Start (StartingIntent As Intent)
    Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub
Sub Service_Destroy
End Sub
Sub Login (usuario As String, password As String)
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Parameters = Array As Object(usuario, password)
    cmd.Name = "login"
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub
Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
        ProgressDialogHide
        ToastMessageShow("Ha ocurrido un error: " & Job.ErrorMessage, True)
    Else
        If Job.JobName = "DBRequest" Then
            reqManager.HandleJobAsync(Job, "ReqManager")
        End If
    End If
    Job.Release
End Sub
Sub ReqManager_Result(result As DBResult)
    Dim Record() As Object
    ProgressDialogHide
    If result.Rows.Size > 0 Then
        Record = result.Rows.Get(0)
        ToastMessageShow( Record(result.Columns.Get("id_empresa")) , False )
        'Starter.kvs.Put("id_empresa", Record(result.Columns.Get("id_empresa")))
'        CargarSites
    Else
        ToastMessageShow("Usuario o contraseña no válidos" , False )
    End If
End SubThanks in advance
 
				 
 
		 
 
		 
 
		 
 
		