InternetAvailabilityChecker icon indicating copy to clipboard operation
InternetAvailabilityChecker copied to clipboard

What if i remove internet cable from wifi router

Open yudhisthira123 opened this issue 6 years ago • 9 comments

Hi Ankit, What if I remove internet cable from wifi router. I am not getting any callback.

My mobile is connected to wifi of router only internet cable is removed from router.

Is this feature supported or not?

yudhisthira123 avatar Apr 11 '18 08:04 yudhisthira123

No, it is not supported. I couldn't find any way to get such callback. Android provides callback whenever there is any change in connectivity. I will try to find some solution for this and will update here. Thanks for reporting this @yudhisthira123 :)

AggarwalAnkit avatar Apr 13 '18 06:04 AggarwalAnkit

this lib can`t support in 28sdk

arudakiya avatar Oct 03 '18 12:10 arudakiya

@arudakiya Sorry for the late response. I am updating this library and you will be able to use it with 28+ sdks soon.

ankitaggarwal1992 avatar Dec 06 '18 12:12 ankitaggarwal1992

@arudakiya Fixed the issue with sdk 28+. Please refer to this commit: efa685873aec38023821979985117ca831f55672

AggarwalAnkit avatar Dec 06 '18 13:12 AggarwalAnkit

Hi @AggarwalAnkit , in this scenario (if the internet cable is removed from router) you can check internet connection by below method.

public static boolean isOnline() { Runtime runtime = Runtime.getRuntime(); try { Process ipProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8"); int exitValue = ipProcess.waitFor(); return (exitValue == 0); } catch (IOException | InterruptedException e) { Log.d(TAG,"Execution: InternetConnectioin Exception : "+e.getMessage()); e.printStackTrace(); } return false; }

zia-ict avatar Feb 25 '19 09:02 zia-ict

@zia-ict the issue is I am not sure if we get a callback in the receiver when internet cable is removed. I don't know the trigger point that is the issue. I we can get the callback somehow then, what this library is doing is fine and will tell if internet is available or not exactly.

AggarwalAnkit avatar Feb 25 '19 09:02 AggarwalAnkit

@zia-ict thanks for reminding me of this issue. Will check it whenever I get time 😃

AggarwalAnkit avatar Feb 25 '19 09:02 AggarwalAnkit

Hi @AggarwalAnkit , If I first connect to other wifi devices (ex: printer, IFE Router, ..) rather than internet router & open App then your library can't trigger onInternetConnectivityChanged(boolean isConnected) method.  Please fix this.

zia-ict avatar Feb 26 '19 05:02 zia-ict

Hi @zia-ict I have fixed the issue which you mentioned regarding connecting to wifi devices rather than internet router. See this commit. The only issue is since it is not connected to internet I am getting this status after some time (actually taking more time than expected). I have set connection timeout also but don't know why it is taking time. I will check it when I get time. If you have any suggestion or solution then you can raise a PR. Thanks 😊

AggarwalAnkit avatar Feb 27 '19 06:02 AggarwalAnkit