zoukankan      html  css  js  c++  java
  • Android Q 使用通知栏消息

    String myChannelId = "iot";
                    String myChannelName = "告警通知服务";
                    NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
                    Notification notification = null;
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                        NotificationChannel channel = new NotificationChannel(myChannelId, myChannelName,
                                NotificationManager.IMPORTANCE_LOW);
                        Toast.makeText(this, myChannelId, Toast.LENGTH_SHORT).show();
                        manager.createNotificationChannel(channel);
                        notification = new NotificationCompat.Builder(this, myChannelId)
                                .setContentTitle("测试")
                                .setContentText("一个新消息")
                                .setWhen(System.currentTimeMillis())
                                .setShowWhen(true)
                                .setSmallIcon(R.mipmap.ic_launcher)
                                .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher))
                                .build();
                    }else {
                        notification = new NotificationCompat.Builder(this, myChannelId)
                                .setContentTitle("This is a title")
                                .setContentText("This is a context")
                                .setWhen(System.currentTimeMillis())
                                .setSmallIcon(R.mipmap.ic_launcher)
                                .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
                                .build();
                    }
                    manager.notify(1, notification);
    
  • 相关阅读:
    杭电ACM 2052 Picture
    杭电ACM求平均成绩
    杭电ACM水仙花数
    cigarettes
    分数加减法
    推荐几个sql server牛人的博客
    npm 介绍
    centos Flash Player插件的安装
    node.js学习(1)
    查询功能:yum [list|info|search|provides|whatprovides] 参数
  • 原文地址:https://www.cnblogs.com/wjw1014/p/12287587.html
Copyright © 2011-2022 走看看