【发布时间】:2018-06-22 22:00:28
【问题描述】:
我的 Wear OS 应用程序中有一个带有操作的通知,我一直在寻找如何在触发通知操作时发送发布请求。有没有办法做到这一点?
我知道 Android Wear 2.0 具有 Internet 功能,并且我看到了打开带有通知的浏览器但没有发送 HTTP 请求的示例。
NotificationManager notificationManager = (NotificationManager) context.GetSystemService(Context.NotificationService);
Intent respondIntent = new Intent(context, typeof(AlarmReceiver));
PendingIntent respontPendingIntent = PendingIntent.GetActivity(context, 0, respondIntent, PendingIntentFlags.UpdateCurrent);
Notification.Action action = new Notification.Action(Resource.Drawable.generic_confirmation,"hello", respontPendingIntent);
var noti = new Notification.Builder(context)
.SetContentTitle("Title").SetContentText("content text")
.SetSmallIcon(Resource.Drawable.pills)
.AddAction(action);
notificationManager.Notify(notificationId, noti.Build());
这就是我目前所拥有的(目前该操作没有做任何事情)。
【问题讨论】:
-
您能否澄清一下您在使用 HTTP 时遇到了什么问题?网络访问在 Wear 上的工作方式与在任何其他 Android 设备上的工作方式基本相同;您通过通知操作执行此操作的事实似乎无关紧要。
-
问题是我还没有找到从通知中的意图/动作发送请求的方法
-
正如我发现没有办法(到目前为止)从意图发送请求。
标签: post action android-notifications wear-os