Android: setOnClickPendingIntent in a statusbar no

2019-08-09 05:57发布

问题:

I made an app that had two buttons in a custom notification whenever it was displayed. I set up an OnClickPendinIntent for each of the buttons, so that they could perform 2 different actions based on which button was pressed. My app worked flawlessly on an AOSP Froyo ROM, but once I upgraded my phone to Gingerbread, the buttons are no longer clickable. Basically, no matter where you press on the notification, it only registers as the notification being clicked. The buttons are being completely ignored.

Is this something that just needs to be coded differently in Gingerbread? Or did the functionality get removed for some reason? And is there any solution to re-enable this functionality?

Thanks.

回答1:

Or did the functionality get removed for some reason?

The functionality was never there in the first place. You cannot put interactive elements on a Notification's RemoteViews. Some devices would support this, but it's not part of the platform.