Android Question jRDC2 connection test

Revisable5987

Member
Licensed User
I'm looking to make it clear in my app when the user is not connected to the database, whether that be due to no internet connection on the device or any other means.

I have come up with the following idea and would like any feedback, I feel like this could be unnecessary extra work for the app and the jRDC2 server.
If there are any better ways to achieve this then I will welcome the ideas.

B4X:
Sub Testconnection
    
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download("http://192.168.1.21:17178/test")
    j.GetRequest.Timeout = 1000
    Wait For (j) JobDone(j As HttpJob)
    
    If j.Success Then
        Log(j.GetString)
        status.Color = Colors.Green
        
    Else
        status.Color = Colors.Red
            
    End If
    j.Release
    Sleep(5000)
    Testconnection
End Sub
 

Revisable5987

Member
Licensed User
I'm not sure if I'm understanding you correctly?
If I remove the code that gets the connection how will I be checking the connection is ok?

I think I might need to learn a bit more ?
On another note, my solution seems to have its issues. Namely blocking activities from starting as the resumable sub calls itself
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
If I remove the code that gets the connection how will I be checking the connection is ok?
you should not remove it. Instead you should create a new handler which does not need a DB connection so the handler is faster ready and faster return a result. Without blocking the Server with a db-connection.
 
Upvote 0

Revisable5987

Member
Licensed User
Okay I might be understanding.. maybe
So currently I'm connecting to the jRDC2 server which is then connecting to the database before returning a result.
If I create a handler that only connects to the jRDC2 server, but NOT the database it will be more efficient?
 
Upvote 0

Revisable5987

Member
Licensed User
Yes. You dont need a db behind if you just want to know internet is working. Or did i misunderstood?
That makes perfect sense, thanks

In regards to the resumable sub blocking other activities, is there anything I can do?
I presume its due to the way I've written the sub.
If it calls itself after 'sleep' whilst switching to a different activity the second activity will open and immediately close
 
Upvote 0

Revisable5987

Member
Licensed User
EDIT: human error

It's the code above in my main question.

I will create an example and start a new thread.


Thanks
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…