通知不显示 [英] Notification Not showing
本文介绍了通知不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
案例分析:我需要一个程序,将在机器人添加通知。当有人点击该通知应该带领他们到我的第二个活动。
我已经建立了一个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.
这篇关于通知不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文