【发布时间】:2015-04-13 10:18:05
【问题描述】:
我尝试在我的通知中点击“builder”中的按钮,但我不能。
我阅读了官方文档:
http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Notification notification = new Notification.Builder(context)
// Show controls on lock screen even when user hides sensitive content.
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setSmallIcon(R.drawable.ic_stat_player)
// Add media control buttons that invoke intents in your media service
.addAction(R.drawable.ic_prev, "Previous", prevPendingIntent) // #0 HERE A BUTTON
.addAction(R.drawable.ic_pause, "Pause", pausePendingIntent) // #1 HERE A BUTTON
.addAction(R.drawable.ic_next, "Next", nextPendingIntent) // #2 HERE A BUTTON
// Apply the media style template
.setStyle(new Notification.MediaStyle()
.setShowActionsInCompactView(1 /* #1: pause button */)
.setMediaSession(mMediaSession.getSessionToken())
.setContentTitle("Wonderful music")
.setContentText("My Awesome Band")
.setLargeIcon(albumArtBitmap)
.build();
我看到了这个帖子:
Android, get Notifications Responses
有人说:
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Notification n = sbn.getNotification();
for(Action action : n.actions){
String title = action.title.toString;
...
}
}
但我不能使用,因为我没有扩展 IntentService 的“NotificationListenerService”
如何单击按钮并在发生事件后?
有谁知道 NotificationListenerService 和 IntentService 的区别?
希望解释正确
【问题讨论】:
-
看到这个Answer
标签: android