如何从手机打开智能手表中的链接



我想知道如何从一个简单的应用程序中打开一个链接,我已经从手机应用程序内推送一个链接到手表上打开,例如一个链接到谷歌play商店应用程序下载到智能手表上。

谢谢。

查看这里的文档https://developer.android.com/reference/androidx/wear/remote/interactions/RemoteActivityHelper

和一个例子https://github.com/android/wear-os-samples/blob/d18c489ff415aa0fbb25c260e3aacdf50f7716e3/WearVerifyRemoteApp/Application/src/main/java/com/example/android/wearable/wear/wearverifyremoteapp/MainMobileActivity.kt

Log.d(TAG, "Number of nodes without app: " + nodesWithoutApp.size)
val intent = Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse(PLAY_STORE_APP_URI))
// In parallel, start remote activity requests for all wear devices that don't have the app installed yet.
nodesWithoutApp.forEach { node ->
lifecycleScope.launch {
try {
remoteActivityHelper
.startRemoteActivity(
targetIntent = intent,
targetNodeId = node.id
)
.await()

最新更新