android开发。帮忙看看我的Notification为什么不显示?
NotificationManagernotificationManager=(NotificationManager)getSystemService(NOTIFICA...
NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification noti = new Notification.Builder(this)
.setContentTitle("new Notification")
.setContentText("哈哈哈哈")
.setSmallIcon(R.drawable.home)
.build();
notificationManager.notify(HELLO_ID, noti);
每次Logcat都显示错误“suppressing Notification from package xxxx by user request” 展开
Notification noti = new Notification.Builder(this)
.setContentTitle("new Notification")
.setContentText("哈哈哈哈")
.setSmallIcon(R.drawable.home)
.build();
notificationManager.notify(HELLO_ID, noti);
每次Logcat都显示错误“suppressing Notification from package xxxx by user request” 展开
3个回答
2014-08-29 · 知道合伙人软件行家
关注
展开全部
少了一个Intent的原因吧,用下边这段代码测试一下.
Builder notification = new NotificationCompat.Builder(context);
notification.setSmallIcon(R.drawable.logo);
notification.setContentTitle("标题");
notification.setContentText("内容");
notification.setAutoCancel(true); //点击自动消息
notification.setDefaults(Notification.DEFAULT_ALL); //铃声,振动,呼吸灯
Intent intent = new Intent(context, MainActivity.class); //点击通知进入的界面
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
notification.setContentIntent(contentIntent);
manager.notify(0, notification.build());
请采纳哈.
Builder notification = new NotificationCompat.Builder(context);
notification.setSmallIcon(R.drawable.logo);
notification.setContentTitle("标题");
notification.setContentText("内容");
notification.setAutoCancel(true); //点击自动消息
notification.setDefaults(Notification.DEFAULT_ALL); //铃声,振动,呼吸灯
Intent intent = new Intent(context, MainActivity.class); //点击通知进入的界面
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
notification.setContentIntent(contentIntent);
manager.notify(0, notification.build());
请采纳哈.
展开全部
这个错大概意思就是说你这个notification没有指定包。
manager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
mNotification = new Notification(R.mipmap.logo, "下载中", System.currentTimeMillis());
mNotification.contentView = new RemoteViews("com.xxxx.xxxx(自己的包名)", R.layout.notification_item);
mNotification.flags = Notification.FLAG_NO_CLEAR;
manager.notify(id, mNotification);
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询