zoukankan      html  css  js  c++  java
  • 添加常驻Notification

      private static final int NOTIFICATION_ID=250;  //用来标示notification,通过notificatinomanager来发布同样标示的notification将更新旧的通知,同时取消notification也需要这个标示(android很多地方都用到标示这么一个玩意)
      
        private void setNotification(String note) {
         //获取系统通知服务
            NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            Notification notification = new Notification();
            notification.icon = R.drawable.notify;   //通知图标,官方文档中说必须有icon才能显示出notification
            notification.when = System.currentTimeMillis();
            notification.tickerText = note;    //通知出现在标题栏时显示的内容
            notification.flags = Notification.FLAG_ONGOING_EVENT; // 设置常驻Flag
            notification.defaults = Notification.DEFAULT_SOUND;   //设置notification的提示音为系统默认提示声音
            notification.setLatestEventInfo(this, "提示消息", note, null);  
            notificationManager.notify(NOTIFICATION_ID, notification);
        }
    
        // 取消通知
        private void cancelNotification() {
            NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            notificationManager.cancel(NOTIFICATION_ID);
        }
     
  • 相关阅读:
    actionscript3.0 图片裁剪及保存jpg详解
    AS3 JPEG Encoder应用:从Flash中保存图片
    Kata 架构
    docker 学习笔记
    processon
    学习容器技术的思考
    cp -f 还是提示是否覆盖
    CentOS下安装桌面环境
    [PYTHON 实作] 算100
    <转>CentOS 7 安装配置 NFS
  • 原文地址:https://www.cnblogs.com/mushishi/p/3394594.html
Copyright © 2011-2022 走看看