Near
Near copied to clipboard
Can makeDiscoverable by service like NSD?
I have a lot of devices and I want to group them by service, can you do it? ex: makeDiscoverable (String hostName, String serviceName);
makeDiscoverable ("My android device", "printer.tcp");
Look for devices that have the "printer.tcp" service registered instead of searching for them all startDiscovery ("printer.tcp")
This doesn't work. But even if it did, everything is searched and then filterd out. (No performance advantage)
And you can build a filter by yourself (e.g. a specific string inside the hostname)
When @adroitandroid creates Release v2.0 you can use it like this:
Kotlin
val nearDiscovery = NearDiscovery.Builder()
.setContext(this)
.setDiscoverableTimeoutMillis(DISCOVERABLE_TIMEOUT_MILLIS)
.setDiscoveryTimeoutMillis(DISCOVERY_TIMEOUT_MILLIS)
.setDiscoverablePingIntervalMillis(DISCOVERABLE_PING_INTERVAL_MILLIS)
.setDiscoveryListener(getNearDiscoveryListener(), Looper.getMainLooper())
.setFilter(Regex("printer.tcp")) // shows only devices with parameter "printer.tcp"
.build()
Java
NearDiscovery nearDiscovery = new NearDiscovery.Builder()
.setContext(this)
.setDiscoverableTimeoutMillis(DISCOVERABLE_TIMEOUT_MILLIS)
.setDiscoveryTimeoutMillis(DISCOVERY_TIMEOUT_MILLIS)
.setDiscoverablePingIntervalMillis(DISCOVERABLE_PING_INTERVAL_MILLIS)
.setDiscoveryListener(getNearDiscoveryListener(), Looper.getMainLooper())
.setFilter(Regex("printer.tcp")) // shows only devices with parameter "printer.tcp"
.build()
Setting Parameter
nearDiscovery.makeDiscoverable("hostName", "printer.tcp")
And the issue can be closed then