android: 停止通知振动
android: stop notification from vibrating
您好,我正在使用
构建通知
NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this, "default")
.setShowWhen(false)
.setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle()
.setMediaSession(mediaSession.getSessionToken())
.setShowActionsInCompactView(0, 1, 2))
.setColor(getResources().getColor(R.color.colorPrimary))
.setSmallIcon(android.R.drawable.stat_sys_headset)
.setContentText(activeAudio.getArtist())
.setContentTitle(activeAudio.getAlbum())
.setContentInfo(activeAudio.getTitle())
.addAction(android.R.drawable.ic_media_previous, "previous", playbackAction(3))
.addAction(notificationAction, "pause", play_pauseAction)
.addAction(android.R.drawable.ic_media_next, "next", playbackAction(2));
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, notificationBuilder.build());
而且我不希望 phone 在创建时振动。我试过了
.setVibrate(null)
.setVibrate(new Long[]{0l})
.setDefaults(Notification.DEFAULT_SOUND)
在所有组合中,但没有效果。有什么想法吗?
您必须卸载该应用程序并重新安装
因为它保存了第一个会话的设置
对于 Android 8 或更高
试试看
mNotificationChannel.setVibrationPattern(new long[]{ 0 });
mNotificationChannel.enableVibration(true);
您好,我正在使用
构建通知NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this, "default")
.setShowWhen(false)
.setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle()
.setMediaSession(mediaSession.getSessionToken())
.setShowActionsInCompactView(0, 1, 2))
.setColor(getResources().getColor(R.color.colorPrimary))
.setSmallIcon(android.R.drawable.stat_sys_headset)
.setContentText(activeAudio.getArtist())
.setContentTitle(activeAudio.getAlbum())
.setContentInfo(activeAudio.getTitle())
.addAction(android.R.drawable.ic_media_previous, "previous", playbackAction(3))
.addAction(notificationAction, "pause", play_pauseAction)
.addAction(android.R.drawable.ic_media_next, "next", playbackAction(2));
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, notificationBuilder.build());
而且我不希望 phone 在创建时振动。我试过了
.setVibrate(null)
.setVibrate(new Long[]{0l})
.setDefaults(Notification.DEFAULT_SOUND)
在所有组合中,但没有效果。有什么想法吗?
您必须卸载该应用程序并重新安装 因为它保存了第一个会话的设置
对于 Android 8 或更高 试试看
mNotificationChannel.setVibrationPattern(new long[]{ 0 });
mNotificationChannel.enableVibration(true);