Happy Friday everyone! Just released the version ...
# feed
m
Happy Friday everyone! Just released the version 1.2.0 of Konnection library with a new library target: JVM. So now, you can use Konnection on your Java target apps (desktop or web). https://github.com/TM-Apps/konnection
🔥 3
p
In Android does it use the new ConnectionRequests callback oriented API or relies on the deprecated synchronous WifiManager and ConnectivityManager APIs? Sorry for asking and not going through the code
m
high now, it's using ConnectivityManager, but I have plans to migrate but looking into documentation, the ConectivityManager is not deprecated https://developer.android.com/reference/android/net/ConnectivityManager
actually, the Android implementation has this:
Copy code
actual fun getCurrentNetworkConnection(): NetworkConnection? =
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        postAndroidMNetworkConnection(connectivityManager)
    } else {
        preAndroidMNetworkConnection(connectivityManager)
    }
p
No, is not fully deprecated, I mean some functions are deprecated not the full API. The synchronous functions were deprecated in favor of a callback API. It seems you are using the right ones. I went over the iOS code and I see the KConnection implementation you chose to throw an exception? Or was me not reading it well on my phone. I would suggest returning a ResultT rather than throws
s
On JVM it tests if either Google, Amazon, Facebook or Apple homepages are available I wonder if using JNI receiving actual system information is available. That would be great. I do a connection check like this, too, but a real system query would be way better.
Great choice of name btw. 😄 💪
👍 1
m
regarding the JVM internet check method, I will try to improve this logic, but by what I saw many projects are using this approach of check well knows websites
s
Yes, because it’s a simple strategy. Easy and fast to implement. The way better method would be asking the OS, but that’s not something you can do quickly if you are in a schedule. For a library doing this properly and also detecting the connection type would be a good place. If you offer that I would remove my custom logic from Ashampoo Photos and use your lib. It’s better information and more stable. Because even alone google going down the „ping“ solution is more like „good enough“, but not actually good.
Ashampoo Photos needs to sync data with cloud services (if people connected them). Based on the connection type (expensive mobile or „free“ WIFI) it decides on when and what to sync. Works good on iOS and Android as we have proper API. On Windows we just need to assume that it will not be a metered connection and hope for the best. 🫣
p
On my experience with the Android API it was a bit unreliable. The latest stuff recommended in the documentation. We ended up with the ping solution to a proprietary endpoint.
👀 1
s
Interesting.
m
for Android implementation, I did many test with different scenarios and the current solution is working properly. I already use it on some Apps. But I understand that this depends on the Android version, I think it's more a system related thing than a SDK APIs related thing
there are many Android libraries that implement the ping solution
s
Because the ping solution is quick and easy to implement with low effort.
For the ping solution a library is not even necessary. It can be done with Ktor very quick. 🤷‍♂️
The real value of a dedicated lib lies in information beyond "we are connected to the internet somehow".
m
just to be clear: my purpose with this library is to be as more as pure possible.
I'm investigating to improve the JVM approach
p
Yes, my problem was when switching networks. Either from WiFi to WiFi or WiFi to LTE
Sometimes the network callback didn't come 😢 Definitely impacted by the device diversity as well. Typical Android problem. So went for a straight forward solution.
s
If you only need to know a boolean "connected" (or not) that's feasible
💯 1
a
@magnumrocha Just a quick feedback. You should be able to utilize Jetpack "App Startup" library to get access to context on Android side... to unify the APIs on all platforms.
👍 1
m
interesting ideia @Armond Avanes, I'll check it, thank you
👍 1