为什么通知振动不再正常工作?

问题描述

为什么所有应用程序在应用程序系统设置中都认禁用通知振动? 是否可以从应用程序检查此状态并打开此设置,以便用户可以启用它? 为什么振动模式被忽略?无论我使用什么,它总是使用认振动。

enter image description here

public void showNotification() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        final CharSequence name = ...;
        final String description = ...;
        final int importance = notificationmanager.IMPORTANCE_HIGH;
        final NotificationChannel channel = new NotificationChannel(...,name,importance);
        channel.setDescription(description);
        final notificationmanager notificationmanager = getContext().getSystemService(notificationmanager.class);
        notificationmanager.createNotificationChannel(channel);
    }

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext(),...)
            .setSmallIcon(R.drawable.ic_notification_icon)
            .setContentTitle(...))
            .setContentText(...)
            .setColor(Color.RED)
            .setLights(Color.RED,1000,1000)
            .setVibrate(new long[]{1000,1000})
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setCategory(NotificationCompat.CATEGORY_EVENT)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC);

    final notificationmanagerCompat notificationmanager = notificationmanagerCompat.from(getContext());
    notificationmanager.notify(NOTIFICATION_ID,builder.build());
}

我在清单中有权限:

<uses-permission android:name="android.permission.VIBRATE" />

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)