android学习笔记---发送状态栏通知
2015-08-13 00:01
441 查看
发送消息的代码如下:
摘自 http://www.tuicool.com/articles/MjuUzi
//获取通知管理器 NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); int icon = android.R.drawable.stat_notify_chat; long when = System.currentTimeMillis(); //新建一个通知,指定其图标和标题 Notification notification = new Notification(icon, null, when);//第一个参数为图标,第二个参数为标题,第三个为通知时间 notification.defaults = Notification.DEFAULT_SOUND;//发出默认声音 Intent openintent = new Intent(this, OtherActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, openintent, 0);//当点击消息时就会向系统发送openintent意图 notification.setLatestEventInfo(this, “标题”, “我是内容", contentIntent); mNotificationManager.notify(0, notification);//第一个参数为自定义的通知唯一标识
摘自 http://www.tuicool.com/articles/MjuUzi
相关文章推荐
- ANDROID链接报错 undefined reference to '__cxa_guard_ac
- 混合应用开发 欢迎界面 (二)
- Android studio插件安装
- Android开发自学笔记(Android Studio1.3.1)—1.环境搭建
- ListView和Adapter
- Android免Root录屏
- EditText 里的属性
- intent.setFlags的参数含义及使用方法
- android 退出时 同时关闭多个activity
- android Ant 批量多渠道打包 总结!
- 【Android性能优化】JAVA内存管理
- 【Android性能优化】Android-Lint:查错与代码优化利器
- Android studio 快捷键汇总
- 在用android的Canvas画图时,调用Canvas.setBitmap方法报错,IllegalStateException
- android错误集锦
- 【Android性能优化】清除Android工程中没用到的资源
- android中Listview的优化技巧
- android控件--ViewPager原理及实现
- Android自定义控件——侧滑菜单(待完善)
- android中多次点击事件的实现