zoukankan      html  css  js  c++  java
  • 定时启动 timerpendingIntent使用

    new Timer().schedule(new TimerTask(){
    
      @Override
    
      public void run(){
    
        //定时发送一个空消息
        handler.sendEmptyMessage(0x123);
      }}, 0, 200};
    }
    //获取系统服务---白拿一个NotificationManager
            NotificationManager notificationManager = (NotificationManager) 
                    super.getSystemService(Activity.NOTIFICATION_SERVICE);
            //用图片,文字,时间, 创造一个notification
            @SuppressWarnings("deprecation")
            Notification notification = new Notification(
                    R.drawable.ic_launcher,
                    "林森通知你",//通知的时候闪一下的几个字
                    System.currentTimeMillis()
                    );
            
            //第三个参数Intent,是notification点击后要做的intent----PendingIntent的意义就是包装一个Intent
            PendingIntent pendingIntent = PendingIntent.getActivity
                    (this, 0, getIntent(), PendingIntent.FLAG_UPDATE_CURRENT);
            
            //拉下来的时候要显示的字,PendingIntent放出notification---设置通知栏的点击事件
            notification.setLatestEventInfo(this, "重要新闻", "四川又地震了", pendingIntent);
            
            notificationManager.notify("tag", R.drawable.ic_launcher, notification);
  • 相关阅读:
    sql server 跨库操作
    FPGA使用技巧
    MATLAB学习(3)
    FPGA统计摄像头输出-基于MD9T112
    zedboard VmodCAM 图像采集 HDMI输出显示
    VmodCAM图像采集 VGA显示
    EDK中如何使用ISE中生成的IP
    如何将HDL文件实例化到XPS中
    ubuntu下安装 Source insight
    VmodCAM 初始化
  • 原文地址:https://www.cnblogs.com/linxiaojiang/p/3038801.html
Copyright © 2011-2022 走看看