简体   繁体   English

Android Wear RemoteControlClient添加“赞”按钮

[英]Android Wear RemoteControlClient add Like Button

I am developing an App that has a lock screen widget where it has a play, pause, prev and next. 我正在开发一个具有锁定屏幕小部件的应用,该小部件具有播放,暂停,上一个和下一个。 When I connect my phone to an Android wear, it automatically shows this buttons and it works fine. 当我将手机连接到Android Wear时,它会自动显示此按钮,并且效果很好。 I would like to add a "Like" button that would automatically be shown on the lock screen and the android wear. 我想添加一个“赞”按钮,该按钮会自动显示在锁定屏幕和Android Wear上。 I know that I can create a Notification and add action for the like. 我知道我可以创建一个Notification并为其添加操作。 But I want to know if is it possible to achieve that using only RemoteControlClient? 但是我想知道是否可以仅使用RemoteControlClient来实现?

Have you tried using rating with the flag FLAG_KEY_MEDIA_RATING ? 您是否尝试过使用带有标志FLAG_KEY_MEDIA_RATING It seems that it's the only way to maintain generic methods and avoid having to set custom code on the wear side (or through notifications). 似乎这是维护通用方法并避免必须在耗材侧(或通过通知)设置自定义代码的唯一方法。

This flag can be set with setTransportControlFlags 可以使用setTransportControlFlags设置此标志

Flag indicating a RemoteControlClient supports ratings. 指示RemoteControlClient支持评级的标志。 This flag must be set in order for components that display the RemoteControlClient information, to display ratings information, and, if ratings are declared editable (by calling addEditableKey(int) with the RATING_KEY_BY_USER key), it will enable the user to rate the media, with values being received through the interface set with setMetadataUpdateListener(OnMetadataUpdateListener). 必须设置此标志,才能使显示RemoteControlClient信息的组件显示分级信息,并且,如果分级被声明为可编辑的(通过使用RATING_KEY_BY_USER键调用addEditableKey(int)),它将使用户能够对媒体进行分级,通过setMetadataUpdateListener(OnMetadataUpdateListener)设置的接口接收值。

Unfortunately, few or not example exists on the web. 不幸的是,网上很少或没有例子。 I discovered only one (unanswered) question relative to this on SO : Android 4.4 KitKat Rating API 我在SO上仅发现一个与此相关的问题(未回答): Android 4.4 KitKat Rating API

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

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