Комментарии:
Ping google
Ответитьjust use net cut program or selfish net from pc to cut internet on ur mobile device on the same network ... if u dont know which ip belong to ur mobile device cut internet on all ip,s on network .. not all mircowaves can cut internet just good one :)
ОтветитьIt may be better than my previous code. My code was created a Runnable, then every 3-sec doing, ping to google. Well, it was work, but at a prolonged usage, it made a memory leak cause the app cache was growing up unpredicted. Maybe with using livedata made the app doesn't creating a big cache, thanks mitch with good explanation.
ОтветитьHow many times it will ping to Google server to know if device actually having internet connection?
ОтветитьHi Mitch, how about for Android TV, it does not work when you disconnect the ethernet cable from the RJ45 jack in the box. How would that go for this case? Thanks in advance!
ОтветитьIssue:-OnAvailable doesn't get called if internet is disconnected and connected again automatically.
Test Case:- You just create hotspot from different phone to test this scenario.
If cellular data is off in the phone where hotspot is created then the other phone show not internet.
If make cellular data on it still shows not connected.
Hi Mitch. Not sure if you still replying to comments, but your solution using connectivity manager requires context. If activity /fragment gets destroyed connectivity manager is leaking the context. How you would go about fixing such memory leak?
Ответитьdota Tshirt respect :Dd
ОтветитьI'm glad you mentioned not turning on the microwave haha
ОтветитьThanks, Mitch for this tutorial. But I guess this one also has a limitation)) When our wifi will be on and after some time there will be no internet, the app won't change the state, because nor onAvailable() or onLost() get called.
ОтветитьHow i can do that for java code
ОтветитьHmmm right but with this implementation, if for example you navigate to another app, disable the connection and then navigate back to your network monitoring app (with the connection disabled), the app won't detect that you have no connection, because when you lost the connection your livedata wasn't subscribed so he didn't update the state. Right?
Ответитьcan you do a java one mitch not familiar with kotlin.
Ответитьi like your t-shirt
ОтветитьDo you get a NPE with this code? ('boolean com.android.org.conscrypt.SslWrapper.isClosed()' on a null object reference)
ОтветитьMay i get the source code of the demo app? You showed just with simple text view
Ответитьwhen you have an internet connection and you launch the app. it's showing connected with the internet.
but when you turn off all networks and lanch the app again it's showing noting. the network callback did not trigger at all until you again turn on the wifi/internet.
hope fully you will reply.
Well in that case, isn't it better to just use socket code instead of any connectivity manager ? Looking for your opinion on it !
ОтветитьHey Mitch ,
Thanks for this awesome video.
I see one issue when app launch then it does not check if network available or not. i think network callback methods called only when network state change i.e onAvailble or onLost called based on network status.
but what happened if before launching app, we change network state. i mean device is offline or connected to internet then launch it
in this case it doesn't check for network availability hence no update in UI. So how do we handle this scenario ?
NET_CAPABILITY_VALIDATED is something that does the same thing under the hood.i have used it and it works fine.
Ответить