Java – how do I determine if an Internet connection is currently available and valid on Android devices?
•
Java
I have this Android application that needs to load data from a remote server over the Internet This update function obviously requires the device to connect not only to some kind of network, but also to the Internet
So: to schedule the update service to a certain date, when it starts, it should determine whether it can actually reach the target server Therefore, a simple "is the device connected to WiFi?" This is not enough because the device may be connected to a wireless network that does not provide Internet access Something like ping is necessary
What is the simplest / best method? If an Internet connection is available, i.e. the server can access it?
Solution
Take a look at this answer on stackoverflow It should be what you are looking for
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码