今天在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.() 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在性能上做了优化。希望有知道的能解释一下

更多相关文章

  1. Android(安卓)EditText OnTouchListener事件重复
  2. ListView下拉加载一(分页)
  3. android 指纹识别 之 BiometricPrompt的简单使用教程
  4. android native ndk崩溃定位
  5. Android双击返回键退出程序代码
  6. Android-NDK开发之基础--Android(安卓)JNI实例代码(四)-- JNI中
  7. android 特效之一 电视机关闭特效
  8. Android屏蔽通知栏的下拉
  9. Android(安卓)Intent.createChooser()

随机推荐

  1. Android surfaceflinger学习笔记之frameb
  2. 【Android】“存储”之普通文件存储(内部
  3. Android 判断应用 第一次启动
  4. android工程中不自动生成Android Depende
  5. android中Invalidate和postInvalidate的
  6. Android开发实践:用PopupWindow实现自定义
  7. Android:Eclipse如何设置格式化Java代码
  8. Android中View自定义XML属性详解以及R.at
  9. Android中的WebView控件用法
  10. 来电防火墙——学习记录