From my android application, how can detect if connection to the server whose IP for example is 192.168.32.232 is lost? Once connection is lost, I want write a service class which will keep on check for connection to the server in the background. If connection is lost my app should show a dialogue box.
Asked
Active
Viewed 748 times
0
-
On a different note: `192.168.32.232` doesn't seem like IP of an server. This resembles to one provided by local network. – Rohit Arya Mar 23 '16 at 07:22
-
How do you initiate the connection between your app and your server ? TCP protocol ? – suns9 Mar 23 '16 at 07:24
-
I just have to check for connection with a server, irrespective of the way I initiated it. – Astra Uvarova - Saturn's star Mar 23 '16 at 07:36
-
It can't be 'irrespective of the way you initiated it'. You may have a socket, an input stream, an output stream, an `HttpURLConnection`, ... Which it is determines the shape of the answer. Details are required. – user207421 Mar 23 '16 at 08:19
1 Answers
0
you can try with a BroadcastReceiver (http://developer.android.com/training/basics/network-ops/managing.html#detect-changes) to peridically check your connection with server, by calling the Kristiyan Varbanov function