Android Question How to test Internet connection without hanging?

Michael Müller Anywhere

Member
Licensed User
Hello,
my app tries to send a string every 2 minutes to a php-script.
I am using an activity with buttons and labels and a Service with
a sub routine that includes:
job1.PostString(URL)

Before sending this I have to check if I have internet-connection
because the activity hangs about 30 seconds when I am sending a string while I am not online.
(It can be that the user is in a area with very low connection)

I have already tried the 2 following ways:
1) ServerSocket.GetMyIP
this shows me that I am online. But I am not realy online.
I can test it with a normal browser too:
It shows me that the websites are not reachable

2)
AsyncDownloader.Download(URL)
a) It works only for 1 call.
b) The activity hangs too, I can not press a button for round about 30 seconds

My question:
Is there a way to test if I have a Internet-connection without hanging
when I have no connection?

Or to reduce the hanging time?

Thank you
 

Cableguy

Expert
Licensed User
There is a lib WiFi related that has a "test internet" method. It tests all type of connections and return true or false...
I just can't remember the name...
 
Top