How to add a button into notification?

前端 未结 2 834
你的背包
你的背包 2020-12-18 17:06

I do it like this:

RemoteViews views = new RemoteViews(..);
views.setOnClickPendingIntent(R.id.button1,pd);
noti.contentviews = views;

and

相关标签:
2条回答
  • 2020-12-18 17:45

    We can made custom notification and put buttons into that and also can perform different functionality on that onClick function, recently I was stuck in the same problem but this link

    Handling buttons inside android notifications

    save my life.

    You can also see my code here Adding button action in custom notification

    and it actually works on my HTC Sensation XE havent tried on other devices yet. So cheer and good luck

    0 讨论(0)
  • 2020-12-18 18:10

    You cannot put interactive widgets, like a Button, in a Notification and get user input from them. These are for output display only.

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