Android Wear - Notification - setContentAction() not working

筅森魡賤 提交于 2019-12-01 05:45:34

Reason:

setContentAction(int index) allow you to specify an action that will be "merged" into the card. It DOES remove this action from "action pages" and it will only be present at your main card. However the reason of your problem is that you do not specify the icon resource for your Action. Without icon it cannot be merged to the main card.

Solution:

You need to specify some icon and add it to your action:

.addAction(new NotificationCompat.Action.Builder(R.drawable.some_icon, null, pendingIntent).build())

If you really do not want any icon you can use a "hack" with empty icon:

empty_icon.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
</shape>


NOTE: setContentIntent(PendingIntent intent) will not make your card clickable. It will just create and add another action (to the most right) with label: "Open".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!