A P2P library for Android for discovery on local networks using UDP and transfer in general using TCP sockets
Extremely helpful for Kotlin applications and almost no change for Java apps
Necessary because ConnectivityManager.CONNECTIVITY_ACTION
is deprecated
Added the possibility to set the port for UDP and TCP, so you can find e.g. only devices that use the same port
Filters can be added to e.g. only find devices that contain a certain string
val nearDiscovery = NearDiscovery.Builder()
.setContext(this)
.setDiscoverableTimeoutMillis(DISCOVERABLE_TIMEOUT_MILLIS)
.setDiscoveryTimeoutMillis(DISCOVERY_TIMEOUT_MILLIS)
.setDiscoverablePingIntervalMillis(DISCOVERABLE_PING_INTERVAL_MILLIS)
.setDiscoveryListener(getNearDiscoveryListener(), Looper.getMainLooper())
.setPort(8989) // optional
.setFilter(Regex("filter")) // optional
.build()
nearDiscovery.makeDiscoverable("hostName", "filter" /* optional */)
This will listen on Port 8989 and will show only Hosts specified the filterText "filter"
This release is entirely thanks to @DATL4G
synchronization related