Android: How to check if Google is available?

后端 未结 3 916
甜味超标
甜味超标 2021-01-22 12:53

Can someone provide better and faster way to check if Google is available in Android? I have observed that connectiontimeout doesnot stop in given time_out. rather it takes more

3条回答
  •  有刺的猬
    2021-01-22 13:25

    As Astral said, you can use BroadcastReceiver to get the status of internet connection and thats the best way to check for internet connection; but if the server you are trying to connect is down or is not responding then just to be on the safe side create a timeout loop. If there's no reply back from the server in specific time then cancel request and show error message to the user.

提交回复
热议问题