1:获取NotificationManager:

NotificationManager m_NotificationManager=(NotificationManager)this.getSystemService(NOTIFICATION_SERVICE);

2:定义一个Notification:

  Notification  m_Notification=new Notification();

3:设置Notification的各种属性:

 //设置通知在状态栏显示的图标
m_Notification.icon=R.drawable.icon;
               
 //当我们点击通知时显示的内容
m_Notification.tickerText="Button1 通知内容.....";
                               
通知时发出的默认声音
m_Notification.defaults=Notification.DEFAULT_SOUND;

//设置通知显示的参数

Intent   m_Intent=new Intent(NotificationDemo.this,DesActivity.class);      
PendingIntent m_PendingIntent=PendingIntent.getActivity(NotificationDemo.this, 0, m_Intent, 0);

m_Notification.setLatestEventInfo(NotificationDemo.this, "Button1", "Button1通知",m_PendingIntent );

//这个可以理解为开始执行这个通知
m_NotificationManager.notify(0,m_Notification);

4:既然可以增加同样我们也可以删除。当然是只是删除你自己增加的。

  m_NotificationManager.cancel(0);   

  这里的0是一个ID号码,和notify第一个参数0一样。

这也就完成了,添加删除工作。

更多相关文章

  1. Android8.0通知适配
  2. Android(安卓)2.1 GPS定位和拍照功能代码
  3. android 获取和设置屏幕亮度
  4. ListView 实现像Android(安卓)Market那样 分页加载 滚动加载
  5. android6.0 netd设置dns
  6. Android(安卓)开发常用代码片段
  7. Ubuntu 下开发 Android(安卓)环境变量设置
  8. 设置默认来电铃声 android
  9. Gps简单更新

随机推荐

  1. checkBox判定
  2. Android(安卓)3G 拨号脚本
  3. ViewPage 翻页滑动
  4. Android获取运营商信息
  5. Android自动填写获取到的验证码
  6. Android(安卓)对象序列化 Serializable实
  7. Android(安卓)Json封装工具类
  8. android 蓝牙 service discovery failed
  9. Android实现异步加载
  10. android widget的预览图