Android开发:notification通知以及通知不显示的问题
2017-05-04 10:59
441 查看
http://blog.csdn.net/chentravelling/article/details/51260063
plain copy
print?
![](https://oscdn.geek-share.com/Uploads/Images/Content/201611/a7c8e286f463007e2a900848b93dd72c.png)
![](https://oscdn.geek-share.com/Uploads/Images/Content/201611/9e12f1d3e499fc949c886e7c9e0484f9)
pushMessageButton = (Button)findViewById(R.id.pushMessage);
final Bitmap largeIcon = ((BitmapDrawable) getResources().getDrawable(R.drawable.stefan)).getBitmap();
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
pushMessageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PendingIntent pendingIntent = PendingIntent.getActivity(BaiDuMapActivity.this, 0, new Intent().setAction(Intent.ACTION_VIEW), 0);
Notification notify= new Notification.Builder(BaiDuMapActivity.this)
.setSmallIcon(R.drawable.head_image)
.setLargeIcon(largeIcon)
.setTicker( "您有新短消息,请注意查收!")
.setContentTitle("Notification Title")
.setContentText("This is the notification message")
.setContentIntent(pendingIntent).setNumber(1).getNotification();
notify.flags |= Notification.FLAG_AUTO_CANCEL; // FL
manager.notify(1,notify);
}
});
![](https://oscdn.geek-share.com/Uploads/Images/Content/201701/9cc493f1e15b23d0f4eaea0d0f8b35d0.png)
2.如果API是16请将getNotification()换成build(),可参考:http://blog.csdn.net/loongggdroid/article/details/17616509
一.notification
[java] viewplain copy
print?
![](https://oscdn.geek-share.com/Uploads/Images/Content/201611/a7c8e286f463007e2a900848b93dd72c.png)
pushMessageButton = (Button)findViewById(R.id.pushMessage);
final Bitmap largeIcon = ((BitmapDrawable) getResources().getDrawable(R.drawable.stefan)).getBitmap();
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
pushMessageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PendingIntent pendingIntent = PendingIntent.getActivity(BaiDuMapActivity.this, 0, new Intent().setAction(Intent.ACTION_VIEW), 0);
Notification notify= new Notification.Builder(BaiDuMapActivity.this)
.setSmallIcon(R.drawable.head_image)
.setLargeIcon(largeIcon)
.setTicker( "您有新短消息,请注意查收!")
.setContentTitle("Notification Title")
.setContentText("This is the notification message")
.setContentIntent(pendingIntent).setNumber(1).getNotification();
notify.flags |= Notification.FLAG_AUTO_CANCEL; // FL
manager.notify(1,notify);
}
});
![](https://oscdn.geek-share.com/Uploads/Images/Content/201701/9cc493f1e15b23d0f4eaea0d0f8b35d0.png)
二.问题
没有notification通知显示。三.解决
1.请设置icon2.如果API是16请将getNotification()换成build(),可参考:http://blog.csdn.net/loongggdroid/article/details/17616509
相关文章推荐
- 【Android开发】消息提示框与对话框-使用Notification在状态栏上显示通知
- android开发视频监控时,抓拍图片存储在相册,图片无法显示问题?通知相册更新即可
- Android开发——Activity销毁时异步任务的保存和恢复、以及相关的进度条的显示问题
- 关于Android Notification.Builder不显示通知的问题
- android系统开发小问题-启动过程中android字符没有显示出来
- Android手机常见问题以及解决办法[非开发]
- Android应用开发基础篇(2)-----Notification(状态栏通知)
- Android应用开发基础篇(2)-----Notification(状态栏通知)
- Android-图像识别项目OpenCV(4):开发思路以及问题
- 开发Android平板电脑程序不能全屏显示问题的解决
- Android中TabHost中实现标签的滚动以及一些TabHost开发的奇怪问题
- android开发模拟器显示图片大小与真实图片大小不一致问题
- 分享Android平板电脑上开发应用程序不能全屏显示的问题解决
- Android综合下载系统的开发步骤以及遇到问题
- Android开发SDK配置以及相关问题的解决
- 自己在使用Android Maps API 开发地图应用程序时遇到的问题,以及解决的办法
- Android开发调试时logcat不显示问题
- Android腾讯微博客户端开发六:给用户加VIP认证以及美化微博显示内容
- 解决Eclipse进行Android开发时logcat不显示问题-使用DDMS
- 关于android语言切换后通知栏显示的问题