Android Wear - Notification - setContentAction() not working

前端 未结 1 1062
耶瑟儿~
耶瑟儿~ 2021-01-13 12:14

I\'m creating a notification that fires from the wearable device and only on the wearable device, not on phone at all. I want it to have two action buttons (no functionality

相关标签:
1条回答
  • 2021-01-13 12:51

    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".

    0 讨论(0)
提交回复
热议问题