Android Question ** Service (httputils2service) Destroy **

Pesciolina

Member
Licensed User
I use this routine within a service to send data to an instrument on a server.
The routine also works perfectly in backuground mode.
The problem arises when I exit the App, the HTTP service is destroyed and the next time the App is started,
the layout is blocked, I exit and re-enter everything ok

Thanks for your help

B4X:
Sub DownLoadLinkServer(Url As String) As ResumableSub
    Dim job As HttpJob
    job.Initialize("",Me)
    job.Download(Url)
    
    Wait For (job) JobDone(job As HttpJob)
    If job.Success Then
        Dim Id As Int
        Dim Num As String
        Dim StringheJobSend() As String
        Dim stringaJobSend1 As String
            
        stringaJobSend1=job.getstring
        '
        StringheJobSend = Regex.Split(";", stringaJobSend1)
            
        Num = StringheJobSend(0)
        Id = sf.Val(StringheJobSend(1))
        If Num = 1 Then
                    
            If Server2 = False Then
                Log("JobRicevuto " & Id )
                'InserisciFlagInviato( ID)
                'CallSub("InserisciFlagInviato",ID)
                
                Wait For (InserisciFlagInviato(Id)) Complete (Result As Int)
                
                'Dim WhereFields As Map = CreateMap("Id": ID)
                'Wait For (DbUtils.UpdateRecord(SQL1,  "TblTempi","Inviato",1,WhereFields)) Complete (Result As Boolean)
                If Result = Id Then
                    CallSubDelayed(Main, "FillWebView")
                    TimerInvioHttp.Enabled = True
                End If
                Log(" Download OK")
            Else
                InserisciFlagInviatoS2( Id)
                '    TimerInvioHttpS2.Enabled = True
            End If
                    
                    
        Else if Num = 2 Then
                    
            CallSubDelayed2(Main, "MessaggioAllert", "Password Errata")
            CallSubDelayed2(Main, "btnWeb_status",False)
                    
            If Server2 = False Then
                TimerInvioHttp.Enabled = False
            Else
                TimerInvioHttpS2.Enabled = False
            End If
                                        
            TimerTestHttp.Enabled=False
            on_line = False
            'cmd_connetti_Click
                    
        Else
            CallSubDelayed2(Main, "MessaggioAllert", "Tempo non Inviato")
            If Server2 = False Then
                TimerInvioHttp.Enabled = True
            Else
                TimerInvioHttpS2.Enabled = True
            End If
            TimerTestHttp.Enabled=False
            on_line = False
                    
        End If
        
    Else
        Log("ERRORE DOWNLOAD")
        
    End If
    job.Release
    Return Id
    
    
End Sub

B4X:
** Service (httputils2service) Destroy **
ignoring event: service_destroy
After accept
handleWindowVisibility: no activity for token android.os.BinderProxy@2cd053b
applied 0 plugin for [B4A.SendTime].
[static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@e52359
hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
applied 0 plugin for [B4A.SendTime].
Create ARC handle: 0x748300c0c0
DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@43b9c15, this = DecorView@42e0b2a[main]
applied 0 plugin for [B4A.SendTime].
@gpudInitialize: successfully initialized with GL, dbg=0 mmdump_dbg=0 mmpath_dbg=0
Surface::connect(this=0x74831eb000,api=1)
Surface::setBufferCount(this=0x74831eb000,bufferCount=3)
Surface::allocateBuffers(this=0x74831eb000)
mapper 3.x is not supported
ioctl c0044901 failed with code -1: Invalid argument
** Activity (main) Create, isFirst = true **
Loading com.google.android.webview version 103.0.5060.71 (code 506007133)
Loaded version=103.0.5060.71 minSdkVersion=29 isBundle=true multiprocess=true packageId=2
Successfully loaded native library
Flushed 9 samples from 9 histograms.
** Activity (main) Resume **
Sucessfully bound to com.google.android.tts
Connected to ComponentInfo{com.google.android.tts/com.google.android.apps.speech.tts.googletts.service.GoogleTTSService}
Set up connection to ComponentInfo{com.google.android.tts/com.google.android.apps.speech.tts.googletts.service.GoogleTTSService}
 

edgar_ortiz

Active Member
Licensed User
Longtime User
The problem arises when I exit the App, the HTTP service is destroyed
As far as I know, this is expected.

You should work on an automatic reconnection process.

For example, save the information of the connected user in a database and clean it when the user logout.
 
Upvote 0
Top