1、当设计音乐播放的时候发现setSmallIcon时候手机状态栏显示的是一块白板,通过查资料发现:系统把icon非透明的部分全变成白色了,原来的icon非透明的部分是黑色自动变为白色了。
若想用黑色的状态栏可以有2种方法:
1.把App目标编译sdk版本降为4.+
2.选择白色的icon
public void startNotification() { mSession = new MediaSession(getApplicationContext(), this.getClass().getName()); int play = musicPlayerState == STATE_PLAY?R.drawable.pause:R.drawable.play; notification = new Notification.Builder(this) .setContentTitle("Music") .setContentText("她说") .setSmallIcon(R.drawable.ab) .addAction(play, "",PendingIntent.getBroadcast(this, 0, new Intent().setAction("android.intent.action.paly"),0)) .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.a)) .setStyle(new Notification.MediaStyle() .setShowActionsInCompactView(0) .setMediaSession(mSession.getSessionToken())) .build(); startForeground(101,notification); }