android:停止振动通知

时间:2019-01-14 13:04:58

标签: android android-notifications android-vibration

您好,我正在使用以下消息构建通知

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());

并且我不希望手机在创建时就振动。我尝试过

.setVibrate(null)
.setVibrate(new Long[]{0l})
.setDefaults(Notification.DEFAULT_SOUND)

所有组合,但无效。有任何想法吗?

1 个答案:

答案 0 :(得分:1)

您必须卸载该应用程序并重新安装 因为它会保存第一次会话中的设置

As presented in this responsum

对于Android 8或更高版本 尝试

UPDATE wp_postmeta
SET
    meta_value = REPLACE(meta_value,
        "Black",
        "Charcoal")
WHERE
    meta_key = "colour"