Более того, мое приложение WearOS работает на переднем плане во время его тестирования.
Вот моя реализация в репозитории:
Код: Выделить всё
getCapableNodesКод: Выделить всё
internal class WearDevicesRepositoryImpl @Inject constructor(
private val nodeClient: NodeClient,
private val capabilityClient: CapabilityClient,
@DispatcherIO
private val ioDispatcher: CoroutineDispatcher,
) : WearDevicesRepository {
override fun getConnectedNodes(): Flow {
return typedFlow {
// This returns the connected watch correctly
nodeClient.connectedNodes.await()
}.flowOn(ioDispatcher)
}
override fun getCapableNodes(): Flow {
return typedFlow {
// This returns an empty list
val capabilityInfo = capabilityClient.getCapability(
CAPABILITY_NAME,
CapabilityClient.FILTER_REACHABLE
).await()
capabilityInfo.nodes.toList()
}.flowOn(ioDispatcher)
}
private companion object {
private const val CAPABILITY_NAME = "watchface_installer"
}
}
Код: Выделить всё
wear/src/main/res/xml/wear_capabilities.xmlКод: Выделить всё
Код: Выделить всё
Код: Выделить всё
dependencies {
// ...
wearApp(project(":wear"))
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... -android-1
Мобильная версия