Hi, i have a simple question.
I have 2 Activitys, if i open the second activity, is the main activity paused. If i make a database querry over RDC then comes this error:
i looked in this forum and found a threat, the solve is to use a service, but if i use a service come this error:
I packed this in to the service module:
here the code of the main activity:
this code works on the main activity but not on the second activity.
and this is the code of the second activity:
What do I have to pack in the service, so I can use several acivitys with the RDC?
Excuse me if I could not express myself well.
I have 2 Activitys, if i open the second activity, is the main activity paused. If i make a database querry over RDC then comes this error:
B4X:
sending message to waiting queue (ser_objecttobytes)
i looked in this forum and found a threat, the solve is to use a service, but if i use a service come this error:
B4X:
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
ResponseError. Reason: java.lang.ClassNotFoundException: com.login.starter$_dbcommand, Response: <html>
<head>
<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 /rdcupload. Reason:
<pre> java.lang.ClassNotFoundException: com.login.starter$_dbcommand</pre></p>
<hr /><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.3.z-SNAPSHOT</a><hr/>
</body>
</html>
Error: <html>
<head>
<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 /rdcupload. Reason:
<pre> java.lang.ClassNotFoundException: com.login.starter$_dbcommand</pre></p>
<hr /><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.3.z-SNAPSHOT</a><hr/>
</body>
</html>
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
I packed this in to the service module:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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
here the code of the main activity:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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 Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private img_preview As ImageView
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("Layout1")
If FirstTime Then
reqManager.Initialize(Me, "http://myip:55/rdcupload")
End If
Activity.LoadLayout("frm_main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btn_upload_Click
Dim picture As Object
picture = reqManager.FileToBytes(File.DirAssets, "testimage01.jpg")
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "upload"
cmd.Parameters = Array As Object(picture, "2")
reqManager.ExecuteCommand(cmd, "1") 'NULL
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success = False Then
Log("Error: " & Job.ErrorMessage)
Else
If Job.JobName = "DBRequest" Then
reqManager.HandleJobAsync(Job, "ReqManager")
End If
End If
Job.Release
End Sub
Sub ReqManager_Result(result As DBResult)
If result.Tag = "1" Then
Msgbox("Upload erfolgreich", "upload")
Else If result.Tag = "2" Then
Dim row() As Object = result.Rows.Get(0)
img_preview.Bitmap = reqManager.BytesToImage(row(0))
Else If result.Tag = "3" Then
Msgbox("Upload erfolgreich", "upload")
'Msgbox(row, "title")
' Dim downpic As Byte = result.Rows
'img_preview.Bitmap = reqManager.BytesToImage(downpic)
End If
reqManager.PrintTable(result)
End Sub
Sub btn_download_Click
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "download"
' cmd.Parameters = Array As Object(picture, "1")
reqManager.ExecuteQuery(cmd,0, "2") 'NULL
End Sub
Sub btn_advanced_Click
StartActivity("advanced")
'Activity.Finish
End Sub
and this is the code of the second activity:
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ts_main As TabStrip
Private ulv_current As UltimateListView
Dim ItemHeight As Int = 268dip
Private lbl_overschrift As Label
Private txb_overschrift As EditText
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("Layout1")
Activity.LoadLayout("frm_admain")
If FirstTime Then
Main.reqManager.Initialize(Me, "http://myip:55555/rdcupload")
End If
ts_main.LoadLayout("frm_left", "middle")
ts_main.LoadLayout("frm_middle", "middle")
ts_main.LoadLayout("frm_right", "right")
ts_main.ScrollTo(1, True)
'ulv_current.AddLayout("ulv_current", "ulv_current_LayoutCreator", "ulv_current_ContentFiller", ItemHeight, True)
'ulv_current.BulkAddItems(20, "ulv_current", 0)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btn_share_Click
Dim picture As Object
picture = Main.reqManager.FileToBytes(File.DirAssets, "testimage02.jpg")
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "uploadall"
cmd.Parameters = Array As Object("1" ,picture, lbl_overschrift.text, "Nürnberg")
Main.reqManager.ExecuteCommand(cmd, "3") 'NULL
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success = False Then
Log("Error: " & Job.ErrorMessage)
Else
If Job.JobName = "DBRequest" Then
Main.reqManager.HandleJobAsync(Job, "ReqManager")
End If
End If
Job.Release
End Sub
Sub ReqManager_Result(result As DBResult)
If result.Tag = "3" Then
Msgbox("Upload erfolgreich", "upload")
'Else If result.Tag = "2" Then
'Dim row() As Object = result.Rows.Get(0)
'img_preview.Bitmap = reqManager.BytesToImage(row(0))
'Msgbox(row, "title")
' Dim downpic As Byte = result.Rows
'img_preview.Bitmap = reqManager.BytesToImage(downpic)
End If
Main.reqManager.PrintTable(result)
End Sub
Sub txb_overschrift_TextChanged (Old As String, New As String)
lbl_overschrift.Text = txb_overschrift.text
End Sub
Excuse me if I could not express myself well.