0
我想设置一个状态栏通知3个以上意向行动,但最大的意图行动,我可以得到只有3:如何设置OnGoing通知?
.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); – 2014-11-25 06:09:05