I am developing an application which connects to the server. By now the login and data transmission works fine if theserver is available. The problem arises when the server is unavailable. In this case the method sends a login request and waits for the response.
Does anyone know how to check if the server is available (visible)?
The pseudocode of the simple logic that has to be implemented is the following:
You can do this by making your own Interface where you declare for example " isServiceRunning() ". You can then bind your Activity to your Service, run the method isServiceRunning(), the Service will check for itself if it is running or not and returns a boolean to your Activity.
In reality, a server is any computer designed to handle requests for information or files. Almost any computer can be converted to run as a server, and this includes Android devices. Even an old iPhone or iPad can be jailbroken and made into a server, but we'll save that for another guide.
Most mobile apps have two parts: client and server. The client side is the app that runs on your device, while the server-side code runs on a remote server. Although the focus of this class is on the client side, we do want students to be able to write some simple server-side code.
He probably needs Java code since he's working on Android. The Java equivalent -- which I believe works on Android -- should be:
InetAddress.getByName(host).isReachable(timeOut)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With