美文网首页
通知 Notification

通知 Notification

作者: 皮皮铭 | 来源:发表于2019-07-15 21:00 被阅读0次
 //创建一个notification
        Notification.Builder builder = new Notification.Builder(this);
        //通知第一次收到的时候在状态栏里显示的消息
        builder.setTicker("你好吗?");
        //点击就会消失
        builder.setAutoCancel(true);
        //通知栏显示的大标题
        builder.setContentTitle("通知");
        //通知栏显示的小的文本内容
        builder.setContentText("你吃了吗");
        //通知栏显示的小图标
        builder.setSmallIcon(R.drawable.ic_launcher_background);
        //点击不会消失 一般用于音乐播放器,下载栏
//        builder.setOngoing(true);
        //点击跳转
        Intent intent = new Intent(getApplicationContext(),MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),1,intent,PendingIntent.FLAG_UPDATE_CURRENT);
        builder.setContentIntent(pendingIntent);
        Notification notification = builder.build();
        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        manager.notify(1, notification);

相关文章

  • notification

    notification文档 桌面通知 notification 示例

  • Notification

    通知Notification

  • Android UI - Notification

    Notification Notification,通知。Android 里的通知设置无非下面几步:创建一个 No...

  • Android Notification的使用

    Notification的作用 能够在通知栏展示一些信息 Notification介绍 notification-...

  • Notification的基本使用和8.0适配

    Notification状态栏通知 1建造者模式构建通知类:Notification.Builder 2通知管理器...

  • 调用摄像头、FileProvider

    1.通知的更多效果  Notification notification = new NotificationCo...

  • 通知Notification

    通过建造者模式来创建通知。为了兼容低版本,v4 Support Library中提供了NotificationCo...

  • 通知(Notification)

    通知是您可以在应用的常规 UI 外部向用户显示的消息。当您告知系统发出通知时,它将先以图标的形式显示在通知区域中。...

  • Notification通知

    一.基本概念 ios提供了两种通知机制,本地通知,推送通知。 本地通知和推送通知可以让不在前端运行的程序告知用户程...

  • Notification通知

    Notification notification是在系统的通知栏中呈现多样式持久性消息的类。 在通知栏显示 消息...

网友评论

      本文标题:通知 Notification

      本文链接:https://www.haomeiwen.com/subject/dewokctx.html