应用在Android 8及更高版本中未显示通知

问题描述

通知在Android 7中工作正常,但是当我尝试在Android 8和Android 10上运行该应用程序时 它不再工作了 我尝试创建一个新的通知频道,但仍然相同 有任何想法吗?

Chronometer.java

  private void createNotificationChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = getString(R.string.channel_name);
        String description = getString(R.string.channel_des);
        String id = getString(R.string.channel_id2);
        int importance = notificationmanager.IMPORTANCE_LOW;
        int notifyID = 1;
        Intent intent = new Intent(this,chronometer.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this,intent,PendingIntent.FLAG_CANCEL_CURRENT);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this,CHANNEL_ID)
                .setContentTitle("Rastreador de uso")
                .setContentText("Acesso rápido ao app")
                .setChannelId(id)
                .setContentIntent(pendingIntent)
                .setAutoCancel(false);
        notificationmanager notificationmanager = getSystemService(notificationmanager.class);
        NotificationChannel channell = null;
        notificationmanager.createNotificationChannel(channell);
        notificationmanager.notify(notifyID,builder.build());
    }
}

解决方法

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

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

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