【发布时间】:2014-11-25 06:02:26
【问题描述】:
我正在尝试设置具有 3 个以上意图操作的状态栏通知,但我可以获得的最大意图操作只有 3 个:
.addAction(R.drawable.btn_previous, "Prev", pendingIntent_Prev_Song)
.addAction(R.drawable.btn_next, "Next", pendingIntent_Next_Song)
.addAction(R.drawable.ic_launcher, "To App", BackToApp_PendingIntent)
无论我添加多少意图操作,它仍然只在状态栏中显示 3 个。 我知道 OnGoing 通知可能是我的解决方案,但如果不重写我的整个代码,我就找不到这样做的方法。
有人可以帮帮我吗?
谢谢你,谢谢
这是我的代码:
mediaPlayer.setWakeMode(getApplicationContext(),PowerManager.PARTIAL_WAKE_LOCK);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
NotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//Back to App Pending Intent
Intent Notification_Intent = new Intent(this, MusicPlayerActivity.class);
BackToApp_PendingIntent = PendingIntent.getActivity(this, 0, Notification_Intent, 0);
//set up notification actions
Intent Prev_Song = new Intent(PREV_SONG);
pendingIntent_Prev_Song = PendingIntent.getBroadcast(this, 0, Prev_Song, 0);
Intent Next_Song = new Intent(NEXT_SONG);
pendingIntent_Next_Song = PendingIntent.getBroadcast(this, 0, Next_Song, 0);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(PREV_SONG);
intentFilter.addAction(NEXT_SONG);
.....
....
public void DisplayMusicStatusBar() {
StatusBarNotification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.play_button)
// .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.btn_play))
.addAction(R.drawable.btn_previous, "Prev", pendingIntent_Prev_Song)
.addAction(R.drawable.btn_next, "Next", pendingIntent_Next_Song)
.addAction(R.drawable.ic_launcher, "To App", BackToApp_PendingIntent)
.setContentText(SongsList.get(SongIndex).get("songTitle"))
.setWhen(System.currentTimeMillis())
// .setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(false)
.setContent(notificationView).build();
NotificationManager.notify(MUSIC_STATUSBAR_ID, StatusBarNotification);
}
【问题讨论】:
-
这样做并更改您的代码,notificationManager.notify(Unique_Integer_Number, notification);
标签: android android-intent android-notifications