Created
June 9, 2022 14:07
-
-
Save molidev8/76a3de9d87d68804f81371068f84d4d3 to your computer and use it in GitHub Desktop.
A function to act as a subscriber in Nearby Share
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun startDiscovering() { | |
val discoveryOptions = | |
DiscoveryOptions.Builder().setStrategy(Strategy.P2P_POINT_TO_POINT).build() | |
client | |
.startDiscovery(SERVICE_ID, object : EndpointDiscoveryCallback() { | |
override fun onEndpointFound(endPointId: String, info: DiscoveredEndpointInfo) { | |
client.requestConnection(android.os.Build.MODEL, endPointId, ConnectingProcessCallback()) | |
.addOnSuccessListener { | |
} | |
.addOnFailureListener { | |
} | |
} | |
override fun onEndpointLost(endPointId: String) { | |
Log.d(GENERAL, "endpoint lost") | |
} | |
}, discoveryOptions) | |
.addOnSuccessListener { Log.d(GENERAL, "discovering...") } | |
.addOnFailureListener { | |
Log.d(GENERAL, "failure discovering...") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment