通知不显示通知

2023-09-04 08:19:15 作者:你的模样

案例分析:我需要一个程序,将在机器人添加通知。当有人点击该通知应该带领他们到我的第二个活动。

我已经建立了一个code。该通知应该是工作,但由于某种原因它不工作。该通知没有显示在所有。不知道我在想什么。

code的那些文件的:

 通知N =新Notification.Builder(本)
                .setContentTitle(与新邮件+test@gmail.com)
                .setContentText(主题)
                .setContentIntent(pIntent).setAutoCancel(真)
                .setStyle(新Notification.BigTextStyle()。bigText(长文本))
                。建立();

        NotificationManager notificationManager =(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
        //隐藏其选中后通知

        notificationManager.notify(0,n)的;
 

作为@dmmh说没有和图标的code不会工作解决方案

。因此,修改code与

  .setSmallIcon(R.drawable.icon)
 

该项目完美地运行。

微信通知栏不显示消息怎么办

Case study: I need a program that will add a notification at android. And when someone click on the notification it should lead them to my second activity.

I have established a code. The notification should be working, but for some reason it is not working. The Notification isn't showing at all. Dont know what am i missing.

Code of those files:

        Notification n = new Notification.Builder(this)
                .setContentTitle("New mail from " + "test@gmail.com")
                .setContentText("Subject")
                .setContentIntent(pIntent).setAutoCancel(true)
                .setStyle(new Notification.BigTextStyle().bigText(longText))
                .build();

        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        // Hide the notification after its selected

        notificationManager.notify(0, n);

解决方案

As @dmmh said the code wont work without and icon. So after modifying the code with

.setSmallIcon(R.drawable.icon)

the project run perfectly.