zoukankan      html  css  js  c++  java
  • ###通知’

    ###通知’

    1. 建立一个通知管理器 ----- NotificationManager

    NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

    1. 创建通知对象------ Notification

    Notification notification = new Notification(R.drawable.ic_launcher, "你来了一个通知", System.currentTimeMillis());

       notification.setLatestEventInfo(this, "通知的标题", "正文 ", null);

    1. 加载通知

     manager.notify(1, notification);

    ###通知’----------制作可点击的通知--------例:打开一个新的通知

    1. 建立一个新的活动
    2. 建立通知管理器

    NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

    1. 创建通知对象

    Notification notification = new Notification(R.drawable.ic_launcher, "你来了一个通知", System.currentTimeMillis());

    1. 创建一个意图

    Intent intent = new Intent(this,ToActivity.class);//此意图是打开TonActivity活动

        PendingIntent pi = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_CANCEL_CURRENT);

    1. 加载通知

          notification.setLatestEventInfo(this, "标题", "我是正文(*^__^*", pi);

             manager.notify(1, notification);

  • 相关阅读:
    day10 作业
    文件操作
    字符编码
    元组、字典、集合内置方法, 深浅拷贝
    day07作业
    一周总结
    mysql操作进阶
    mysql操作篇续
    mysql-操作篇
    mysql的安装
  • 原文地址:https://www.cnblogs.com/tangwanzun/p/5702270.html
Copyright © 2011-2022 走看看