Android O使用通知遇到的坑
来源:互联网 发布:二级数据库程序设计类 编辑:程序博客网 时间:2024/06/14 06:17
今天在Android 8.0上使用通知的时候,遇到一个问题,只要一发出通知,就弹出系统界面已停止运行的弹框。如下图所示
代码如下:
NotificationChannel chan1 = new NotificationChannel(PRIMARY_CHANNEL, "cd", NotificationManager.IMPORTANCE_DEFAULT);chan1.setLightColor(Color.GREEN);chan1.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);notificationManager.createNotificationChannel(chan1);builder = new Notification.Builder(getApplicationContext(), PRIMARY_CHANNEL) .setContentTitle("ds") .setContentText("fa") .setSmallIcon(R.mipmap.ic_launcher) .setAutoCancel(true);notificationManager.notify(NOTI_ID, builder.build());
Log显示如下:
I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:19
I/DynamiteModule: Selected remote version of com.google.android.gms.maps_dynamite, version >= 19
I/Google Maps Android API: Google Play services client version: 11400000
I/Google Maps Android API: Google Play services package version: 11745036
I/zygote64: Do full code cache collection, code=124KB, data=85KB
I/zygote64: After code cache collection, code=122KB, data=70KB
I/zygote64: Do partial code cache collection, code=124KB, data=73KB
I/zygote64: After code cache collection, code=124KB, data=73KB
I/zygote64: Increasing code cache capacity to 512KB
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
I/Choreographer: Skipped 77 frames! The application may be doing too much work on its main thread.
W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:4
I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 4
W/zygote64: Verification of void j.<clinit>() took 305.110ms
刚开始根据log在google上搜了半天,没半点眉目,之后很无奈的一行一行的注释掉代码排除问题所在。结果发现
builder = new Notification.Builder(getApplicationContext(), PRIMARY_CHANNEL) .setContentTitle("ds") .setContentText("fa") .setSmallIcon(R.mipmap.ic_launcher) .setAutoCancel(true);把上面红色部分注释掉,正常,取消注释就崩掉,那么这就是问题所在了。把图片复制到drawable-xx文件夹下,
setSmallIcon(R.mipmap.ic_launcher)改为 setSmallIcon(R.drawable.ic_launcher)就正常了。虽然问题解决了,但是依然很困惑。drawable和
mipmap在使用上应该是一样的,只是mipmap在性能上做了优化。希望有知道的能解释一下
- Android O使用通知遇到的坑
- 使用 Android 自定义通知Notification时遇到的问题
- Android O之通知
- iOS 通知 遇到的坑
- 通知Notification遇到的坑
- android通知的使用
- Android 通知的使用
- android 自定义通知栏遇到的问题
- 使用通知中心NSNotificationCenter遇到的问题
- Android O(8.0)通知栏适配
- android中通知的使用
- android通知(Notification)的使用
- Android:通知栏的使用
- android Notification(通知) 的使用
- Android 通知栏的使用
- Android中通知的使用
- Android通知Notification的使用
- Android:通知栏的使用
- ubuntu 下配置python 遇到的问题
- 微信小程序开发环境搭建
- web前端技术框架选型参考
- WCF学习笔记二:客户端调用控制台宿主程序
- Java RMI远程方法调用详解
- Android O使用通知遇到的坑
- 【猜测】使用神经网络算法的时候权值可视化观察
- C语言简单实现冒泡排序算法
- EditText在输入内容时延迟、卡顿
- JAVA图书管理系统(JSP+Servlet)
- centOS安装Apache OpenOffice方法
- Linux下双tomcat配置全局变量和sh变量配置
- linux ls 显示便于阅读的文件大小
- Java面向对象习题