android 通知(android 8.0可用)
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可用)的更多相关文章
- Android通知Notification全面剖析
通知 通知是您可以在应用的常规 UI 外部向用户显示的消息.当您告知系统发出通知时,它将先以图标的形式显示在通知区域中.用户可以打开抽屉式通知栏查看通知的详细信息. 通知区域和抽屉式通知栏均是由系统控 ...
- [原]如何在Android用FFmpeg+SDL2.0解码图像线程
关于如何在Android上用FFmpeg+SDL2.0解码显示图像参考[原]如何在Android用FFmpeg+SDL2.0解码显示图像 ,关于如何在Android使用FFmpeg+SDL2.0解码声 ...
- Android 通知 相关api记录
记录帖 通知(Notification) 的API 1.使用getSystemService()方法获取系统服务,参数接收一个字符串来确定获取具体的服务,使用通知传入Content.NOTIFICAT ...
- android 版本更新适配8.0,解决8.0手机无法更新自动安装apk
随着android 7.0的普及android 8.0的也逐渐流行起来,那么google对权限方面又有了新的修改.而且我发现在android8.0中除了一些bug,比如说:在小米6(Android 8 ...
- Android 通知之 Notification
Notifications | Android Developershttp://developer.android.com/guide/topics/ui/notifiers/notificatio ...
- Android判断当前网络是否可用--示例代码
Android判断当前网络是否可用--示例代码 分类: *07 Android 2011-05-24 13:46 7814人阅读 评论(4) 收藏 举报 网络androiddialogmanagern ...
- Android之检查网络是否可用(跳转网络设置页面)
private boolean NetWorkStatus() { ConnectivityManager cwjManager = (ConnectivityManager) getSystemSe ...
- [原]如何在Android用FFmpeg+SDL2.0之同步音频
同步音频的原理可以参考:http://dranger.com/ffmpeg/tutorial05.html 本文是在 [原]如何在Android用FFmpeg+SDL2.0之同步视频 的基础上面继续 ...
- android检测当前网络是否可用
在android程序中运行第一步就是检测当前有无可用网络 如果没有网络可用就退出程序 if (isConnect(this)==false) { ...
- android ——通知管理
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle saved ...
随机推荐
- 剑指Offer:合并两个排序的链表【25】
剑指Offer:合并两个排序的链表[25] 题目描述 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. 题目分析 每次都是比较箭头节点,把小节点连接到已经合 ...
- 第一个自定义开发的Arcgis地图
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- atol实现【转】
int my_atoi(const char *str) { assert(str != NULL); ; ; while(*str == ' ' || *str == '\n' || *str == ...
- HTML5 <template>
http://www.zhangxinxu.com/wordpress/2014/07/hello-html5-template-tag/
- ansible安全优化建议
摘自 ansible自动化配置书籍,特此感谢 针对非授权连接和截取通信息等共计行为,我们总结了9条方法: 使用安全加密的通信方式 禁止root用户远程登录并充分利用sudo 移除非必须的软件,只开放需 ...
- 继续servlet理论篇
唉,毕业是件很麻烦的事情,实习也是一件很郁闷的事情,现在公司很注重基础,所以 所以还要看java,不过,我年轻,我有激情.来吧,来着不惧,说这话,有些心虚. HttpServlet类中所提供的doGe ...
- ssh整合 小例子
实现了用户的查插删改操作. 原理:struts负责接收.分发请求.spring采用面向接口编程的思想整合整体框架,负责连接数据库.hibernate负责操作数据库语言. 思路: 1.配置struts的 ...
- html5--5-6 绘制圆/弧
html5--5-6 绘制圆/弧 学习要点 掌握arc() 方法创建圆弧/曲线(用于创建圆或部分圆) 矩形的绘制方法 rect(x,y,w,h)创建一个矩形 strokeRect(x,y,w,hx,y ...
- cassandra 存储二进制data
Blob type The Cassandra blob data type represents a constant hexadecimal number defined as 0[xX](hex ...
- codeforces 702C C. Cellular Network(水题)
题目链接: C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input st ...