0

I know there are a lot of examples for this question, but couldn't find any better solution (except of this, but not working on kotlin). In most examples if there's no internet connection goes to exception and crashs app.

So, Is it possible to show Dialog/Toast with no internet error?

Abduhafiz
  • 3,318
  • 5
  • 38
  • 48
  • you can have a connection but no internet so you can try to connect to a web socket and check for internet https://stackoverflow.com/a/27312494/8528047 – Pemba Tamang Sep 27 '19 at 11:35
  • Yes, you can override the `onInternetUnavailable()` in the activity and display Dialog/Toast. – Jaymin Sep 27 '19 at 11:35
  • your approach is correct, can you provide your LogCat when crash occurs ? – GianhTran Sep 27 '19 at 11:36
  • there is no such thing that works in java and doesn't work in kotlin, you are making a mistake somewhere. – Daniel Sep 27 '19 at 11:39
  • I'm using MVVM pattern and when I call onInternetUnavailable() in my Activity, mInternetConnectionListener is always null. – Abduhafiz Sep 27 '19 at 11:55
  • Possible duplicate of [How to check internet access on Android? InetAddress never times out](https://stackoverflow.com/questions/1560788/how-to-check-internet-access-on-android-inetaddress-never-times-out) – Vivek Mishra Sep 27 '19 at 12:06

0 Answers0