Android Question Sending message to waiting queue (ser_objecttobytes)

Alexander Stolte

Expert
Licensed User
Longtime User
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:

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
this code works on the main activity but not on the second activity.

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
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.
 

Alexander Stolte

Expert
Licensed User
Longtime User
then 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 **
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
it dosent work :/

B4X:
#AdditionalJar: com.android.support:support-v4
#Region  Project Attributes
    #ApplicationLabel: Upload Picture
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: 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.
   
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
        'Starter.reqManager.Initialize(Me, "http://myip:55555/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 = Starter.reqManager.FileToBytes(File.DirAssets, "testimage01.jpg")
   
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "upload"
   
    cmd.Parameters = Array As Object(picture, "2")
    Starter.reqManager.ExecuteCommand(cmd,  "1") 'NULL
End Sub
Sub yeah(result49 As Object)
    img_preview.Bitmap = result49
End Sub


Sub btn_download_Click
    CallSub(Starter, "cmd77")
   
   
End Sub

Sub btn_advanced_Click
   
    StartActivity("advanced")
    'Activity.Finish
End Sub

B4X:
#Region  Service Attributes
    #StartAtBoot: True
    #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.
    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
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.

End Sub

Sub Service_Start (StartingIntent As Intent)
    reqManager.Initialize(Me, "http://myip:55555/rdcupload")
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

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)
        CallSubDelayed2(Main, "yeah", reqManager.BytesToImage(row(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 cmd77
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "download"
   
    '    cmd.Parameters = Array As Object(picture, "1")
    reqManager.ExecuteQuery(cmd,0,  "2") 'NULL
End Sub

the log say this:

B4X:
<head>

** 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>
 
Upvote 0
Top