开发者

How to add a button into notification?

开发者 https://www.devze.com 2023-04-02 20:35 出处:网络
I do it like this: RemoteViews views = new RemoteViews(..); views.setOnClickPendi开发者_C百科ngIntent(R.id.button1,pd);

I do it like this:

RemoteViews views = new RemoteViews(..);
views.setOnClickPendi开发者_C百科ngIntent(R.id.button1,pd);
noti.contentviews = views;

and then notify the notification. I can see the button in the notification, but the button can't be clicked. When i click the button,the whole notification clicked! How can i resolve this question? I found everywhere for this,but nothing useful found. someone said, some phones don't support the notification button, but samsung galaxy s, the musicplayer's notification has button click event.


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


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

精彩评论

暂无评论...
验证码 换一张
取 消