Android中通知的使用
来源:互联网 发布:日本人长相知乎 编辑:程序博客网 时间:2024/05/01 02:54
通知的创建步骤
1.获取通知的管理类NotificationManager
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
API11以上弃用一下方法
2.创建一个Notification对象(用于存储通知所需的各种信息)
参数解释:1.图片 2.指定通知ticker内容,当通知刚被创建的时候,它会再系统的状态栏一闪而过,属于一种顺势的提示信息。 3.指定通知的创建时间,以毫秒为单位
Notification notification = new Notification(R.drawable.icon, “This is ticker text”, System.currentTimeMillis());
3.对通知的布局进行设定.(调用setLatestEventInfo()方法给通知设置一个标准的布局)
参数解释:1.Context 2.指定通知的标题内容 3.指定通知正文内容
notification.setLatestEventInfo(context, “This is content title”, “This is content text”, null);
4.显示通知(调用NotificationManager的notify()方法显示通知)
参数解释:1.保证为每个通知所指定的id都是不同 2.Notification对象
manager.notify(1, notification);
PendingIntent
PendingIntent和Intent有些类似,它们都可以去指明某一个‘意图’,都可以用于启动活动、启动服务以及发送广播等。不同的是,Intent更加倾向于去立即执行某个动作,而PendingIntent更加倾向于在某个合适的时机去执行耨个动作。所以,也可以把PendingIntent简单地理解为延迟执行的Intent.
- android中通知的使用
- Android中通知的使用
- Android中通知的简单使用和自定义通知样式
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- android中通知栏notification的使用
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知栏的使用
- Notification,Android中通知的使用
- Android中通知的使用-----Notification详解
- Android中Notification 通知的使用
- Android中Notification 通知的使用
- 新的微单到手
- Android Studio的基本设置
- 正则表达式
- 广播注册和添加权限过滤广播
- STL 之 C++ Map容器的简单使用方法
- Android中通知的使用
- 303. Range Sum Query - Immutable [Leetcode]
- 堆 栈(转载)
- MySql+Mybatis+Druid:sql injection violation, multi-statement not allow
- IOS core data遇到问题集合
- Log4j2完全讲解 附项目集成源码下载
- 237,Mac上使用Charles抓包
- Android 之采用execSQL和rawQuery方法完成数据的添删改查操作
- PostgreSQL COPY 导入/导出数据