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