1
我正在开发基于Android Nearby的项目。我能为操作添加超时的请求连接或发送有效载荷,但它已经不可能,使其工作在发现和广告流程...启动发现和开始广告超时不适用于Android附近
Nearby.Connections.startDiscovery(
googleApiClient,
getServiceId(),
object : EndpointDiscoveryCallback() {
override fun onEndpointFound(endpointId: String, info: DiscoveredEndpointInfo) {
Log.d(TAG,
String.format(
"onEndpointFound(endpointId=%s, serviceId=%s, endpointName=%s)",
endpointId, info.serviceId, info.endpointName))
if (getServiceId() == info.serviceId) {
val endpoint = Endpoint(endpointId, info.endpointName)
discoveredEndpoints.put(endpointId, endpoint)
onEndpointDiscovered(endpoint)
}
}
override fun onEndpointLost(endpointId: String) {
Log.d(TAG, String.format("onEndpointLost(endpointId=%s)", endpointId))
}
},
DiscoveryOptions(STRATEGY))
.setResultCallback({ status -> onResult(ConnectionCase.START_DISCOVERY, status) }, TIMEOUT_DISCOVERY_MILLIS, TimeUnit.MILLISECONDS)
private val TIMEOUT_DISCOVERY_MILLIS: Long = 1000
我假装与超时是为了避免等待,直到青睐的设备找到另一个与之配对的连接。有没有人有这个问题?