final String CHANNEL_ID = "com.chao.channel.id";
final String CHANNEL_NAME = "com.chao.channel.name"; NotificationManager mManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification.Builder builder = null; if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O){
builder = new Notification.Builder(this);
}else{
/**
* Oreo不用Priority了,用importance
* IMPORTANCE_NONE 关闭通知
* IMPORTANCE_MIN 开启通知,不会弹出,但没有提示音,状态栏中无显示
* IMPORTANCE_LOW 开启通知,不会弹出,不发出提示音,状态栏中显示
* IMPORTANCE_DEFAULT 开启通知,不会弹出,发出提示音,状态栏中显示
* IMPORTANCE_HIGH 开启通知,会弹出,发出提示音,状态栏中显示
*/过
NotificationChannel notificationChannel = new
NotificationChannel(Config.CHANNEL_ID, Config.CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); //如果这里用IMPORTANCE_NOENE就需要在系统的设置里面开启渠道, //通知才能正常弹出
mManager.createNotificationChannel(notificationChannel);
builder = new Notification.Builder(this,Config.CHANNEL_ID);
}
notification = builder.build();
mManager.notify(555, notification);

部分机型使用IMPORTANCE_LOW MIN NONE仍然发出提示音问题,修改channelId,可以解决

android 通知(android 8.0可用)的更多相关文章

  1. Android通知Notification全面剖析

    通知 通知是您可以在应用的常规 UI 外部向用户显示的消息.当您告知系统发出通知时,它将先以图标的形式显示在通知区域中.用户可以打开抽屉式通知栏查看通知的详细信息. 通知区域和抽屉式通知栏均是由系统控 ...

  2. [原]如何在Android用FFmpeg+SDL2.0解码图像线程

    关于如何在Android上用FFmpeg+SDL2.0解码显示图像参考[原]如何在Android用FFmpeg+SDL2.0解码显示图像 ,关于如何在Android使用FFmpeg+SDL2.0解码声 ...

  3. Android 通知 相关api记录

    记录帖 通知(Notification) 的API 1.使用getSystemService()方法获取系统服务,参数接收一个字符串来确定获取具体的服务,使用通知传入Content.NOTIFICAT ...

  4. android 版本更新适配8.0,解决8.0手机无法更新自动安装apk

    随着android 7.0的普及android 8.0的也逐渐流行起来,那么google对权限方面又有了新的修改.而且我发现在android8.0中除了一些bug,比如说:在小米6(Android 8 ...

  5. Android 通知之 Notification

    Notifications | Android Developershttp://developer.android.com/guide/topics/ui/notifiers/notificatio ...

  6. Android判断当前网络是否可用--示例代码

    Android判断当前网络是否可用--示例代码 分类: *07 Android 2011-05-24 13:46 7814人阅读 评论(4) 收藏 举报 网络androiddialogmanagern ...

  7. Android之检查网络是否可用(跳转网络设置页面)

    private boolean NetWorkStatus() { ConnectivityManager cwjManager = (ConnectivityManager) getSystemSe ...

  8. [原]如何在Android用FFmpeg+SDL2.0之同步音频

    同步音频的原理可以参考:http://dranger.com/ffmpeg/tutorial05.html  本文是在 [原]如何在Android用FFmpeg+SDL2.0之同步视频 的基础上面继续 ...

  9. android检测当前网络是否可用

    在android程序中运行第一步就是检测当前有无可用网络  如果没有网络可用就退出程序  if (isConnect(this)==false)           {                ...

  10. android ——通知管理

    public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle saved ...

随机推荐

  1. 关于ActiveMQ接收端停止接收的方法

    现在有一个需求: 在发送端服务器出现故障后,接收端的接收方法要停下来,关于停止接收的方法,我做了下面这些事情: // 获取 ConnectionFactory ConnectionFactory co ...

  2. [Java SE] 字符串连接

    Java 支持多种字符串连接方式,总结如下: package cn.spads.tool.string; import java.text.MessageFormat; /** * <b> ...

  3. Java内存模型(JMM)中的happens-before

    happens-before是JMM中最核心的概念,对于Java程序员来说,理解happens-before是理解JMM的关键 . 1.JMM的设计 首先,来看看JMM的设计意图.从JMM的设计者的角 ...

  4. Java网络编程InetAddress类

    InetAddress用来代表IP地址.一个InetAdress的对象就代表着一个IP地址, getByName(String host):在给定主机名的情况下确定主机的 IP 地址,主机名可以是机器 ...

  5. swoole异步redis安装前置条件和流程

    ---恢复内容开始--- 1.redis服务 确认redis在服务器中已经安装了 2.hiredis库 第二步安装hiredis 下载位置 2.1获取 安装包https://github.com/re ...

  6. Oracle数据常用操作

    将用逗号隔开字段拆分成两行: select * from mp_fs_file_info a,dm_process_upload b where instr(b.attachment,a.file_i ...

  7. python 模块和模块sys.argv

    In [5]: import os In [6]: os.__file__ Out[6]: '/usr/local/lib/python2.7/os.pyc' In [7]: import rando ...

  8. 「LuoguP2252」 取石子游戏(威佐夫博弈

    [P2252]取石子游戏 - 洛谷 题目背景 无 题目描述 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以 ...

  9. bzoj 2169 连边——去重的思想

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2169 如果之前都去好重了,可以看作这次连的边只会和上一次连的边重复. 可以认为从上上次的状态 ...

  10. This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended

    VS2005转换成VS2010时出现的问题: This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x05 ...