Android 通知(Notification)
2015-12-17 23:26
453 查看
/**
*
* @param icon 引入图片
* @param tickerText 程序在后台运行的时候通知显示提示显示的内容
* @param context 上下文
* @param contentTitle 通知标题
* @param contentText 通知内容
* @param id 通知id
* @param pendingIntent 通过PendingIntent对象来处理点击通知后的逻辑操作
*/
public void MyNotification(int icon,String tickerText,Context context,String contentTitle,String contentText,int id){
//获取NotificationManager对象,通过NotificationManager对象进行管理
NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
//获取Notification对象
Notification notification = new Notification(icon,tickerText, System.currentTimeMillis());
//获取Intent对象 点击通知启动com.example.viewpager.PendingIntent活动
Intent intent = new Intent(getApplicationContext(), com.example.viewpager.PendingIntent.class);
//获取PendingIntent 对象
PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
//设置通知的标题和通知文本
notification.setLatestEventInfo(context, contentTitle, contentText, pi);
//显示通知 每个通知的id不能重复
notificationManager.notify(id, notification);
}
相关文章推荐
- 从J2EE转向Android的第十天-----对话框(Dialog)和通知(Notification)
- Android Notification之监听系统清除通知栏方法
- Android中的通知—Notification
- Android 通知栏发送消息Notification(可以使用自定义的布局)
- 系出名门Android(3) - 对话框(Dialog)和通知(Notification)
- Android Notification 通知封装成工具类
- Android 通知栏Notification的整合 全面学习
- Android中通知栏Notification详解以及自定义Notification
- Android Notification自定义通知样式你要知道的事
- Android之状态栏通知Notification、NotificationManager详解
- Android 通知栏Notification的整合 全面学习
- android开发之Notification_通知栏消息
- Android中通知(Notification)的简单使用
- android开发之Notification_通知栏消息
- 使用android push notification service 实现即时通知
- Android 通知栏Notification的整合 全面学习 (一个DEMO让你完全了解它)
- 自学Android之通知Notification
- Android 通知使用权(NotificationListenerService)的使用
- Android 通知栏Notification的整合 全面学习 (一个DEMO让你完全了解它)
- Android消息通知(notification)和PendingIntent传值