简体   繁体   English

如何从电话创建的通知中打开磨损活动

[英]How to open a Wear Activity from a Notification created by Phone

Currently when I receive a Push notification I create a notification. 目前,当我收到推送通知时,我会创建一个通知。 This notification is shown on phone and Android wear. 此通知显示在手机和Android上。 The notification has one action: Open on phone. 通知有一个操作:打开电话。

How can I create a second action to open an Activity on the wearable? 如何创建第二个操作以在可穿戴设备上打开活动?

I tried using NotificationCompat.WearableExtender and adding an action. 我尝试使用NotificationCompat.WearableExtender并添加操作。 But how can I use the Wear Activity in the PendingIntent? 但是如何在PendingIntent中使用Wear活动? Because the Wear Activity is in another module I don't have access to it in my Phone module, where the Push notification is received. 由于Wear Activity在另一个模块中,因此我无法在收到Push通知的Phone模块中访问它。

You cannot open an activity on a wear device using a notification that was created on a phone; 您无法使用手机上创建的通知在磨损设备上打开活动; all the actions/intents refer to the originator of the notification (ie phone if phone created the notification). 所有动作/意图都指通知的发起者(即电话创建通知时的电话)。 You need to do a bit of work to create the effect that you want; 你需要做一些工作来创造你想要的效果; basically need to have a wear app as well and instead of creating a notification on the phone for wear, send a message, from your phone to the wear device and have teh wear app on your wear device capture that message and create a notification on the wear device. 基本上还需要一个磨损应用程序,而不是在手机上创建一个通知,以便穿戴,发送消息,从您的手机到磨损设备,并在您的磨损设备上佩戴应用程序捕获该消息,并创建一个通知穿戴装置。 Then that notification can open an activity (since it was originated on your wear device). 然后该通知可以打开一个活动(因为它来自您的磨损设备)。 As a sample app, take a look at the SynchronizedNotifications that does this. 作为示例应用程序,请查看执行此操作的SynchronizedNotifications

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM