Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Problem when receiving internet connectivity in Android P (API 28) #299
Hi guys! Great job with this lib!
I just wanted to report a small issue that I'm having while receiving internet connectivity.
I'm using the following:
This is always returning false, but just in Android P. Any other version works fine.
I read about Android P is restricting network status access and I'm not sure if there can be a problem related to that, what do you guys think? Have any of you found a similar issue and respective solution?
Thanks in advance!
Thanks for the quick response!
There isn't any error or exception being throwed. The thing is it simply returns false, and our app reacts according to that response. In our case we show a no connection screen.
If I use the NetworkInfo class to get access to connectivity, it returns true, and everything works fine.
I haven't investigated it yet, but I have two suggestions for now:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.INTERNET"/>
InternetObservingSettings .strategy(new SocketInternetObservingStrategy()) .host(...) .port(...) ... // other settings go here .build()
Moreover, you can also use
I had already implemented the first suggestion, but not the second. Even so, it didn't work.
We really want to validate more than just the network connectivity, but for now, we will use it as a workaround. I look forward for any updated on this.
Thank you for your help!
I know, what's going on.
It's related to the security issues. Starting with Android 9.0 (API level 28), cleartext support is disabled by default.
The quickfix will be setting
<application ... android:usesCleartextTraffic="true" >
You can check this commit: f1b21ba to see how it's done in the sample apps.
You can also read about more details and other options of dealing with this problem here: https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted
I've added task in #300 regarding documentation of this thing.
I think, it's clear now and we can close this issue.
hi, @pwittchen sorry for bothering but wouldn't it better/enough just to switch to
Ok, I thought that on Android P would be enough to replace any clear text communication with secure one. I'm getting on emulator:
Why wouldn't changing to https in