Android Уведомление перестает вибрировать и звучать, когда пользователь проверяет его - PullRequest
0 голосов
/ 24 марта 2020

У меня есть android уведомление, которое перестает звучать и вибрировать, когда пользователь проверяет вкладку уведомлений. Не так, как Notification.FLAG_INSISTENT, когда уведомление постоянно вибрирует.

Я просто хочу, чтобы мое уведомление завершало свою звуковую и вибрационную схему один раз, даже если пользователь проводит пальцем, чтобы проверить вкладку уведомления.

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){

    @SuppressLint("WrongConstant")
    NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
            NotiName, NotificationManager.IMPORTANCE_MAX);
    notificationChannel.setDescription(NotiDesc);
    notificationChannel.enableLights(true);
    notificationChannel.setLightColor(Color.RED);
    notificationChannel.enableVibration(true);
    notificationChannel.setVibrationPattern(new long[]{500, 200, 500, 200, 500, 200});
    notificationChannel.setSound(soundUri, audioAttributes);

    notificationManager.createNotificationChannel(notificationChannel);

}

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this,NOTIFICATION_CHANNEL_ID);
notificationBuilder.setAutoCancel(true)
        .setDefaults(Notification.DEFAULT_ALL)
        .setWhen(System.currentTimeMillis())
        .setSmallIcon(R.drawable.notify_icon)
        .setContentTitle(title)
        .setContentText(body)
        .setContentIntent(pendingIntent)
        .setPriority(NotificationCompat.PRIORITY_HIGH)
        .setContentInfo("info");

notificationManager.notify(msgval, notificationBuilder.build());
...