当前位置:   article > 正文

Android实现3种Notification(状态栏通知)悬挂式Notification,是Android 5.0系统中新增的_notification android 5.0

notification android 5.0

Android实现3种Notification(状态栏通知)

悬挂式Notification,是Android 5.0系统中新增的

  1. NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
  2. .setContentTitle(title)
  3. .setContentText(message)
  4. .setContentIntent(intent)
  5. .setWhen(System.currentTimeMillis())
  6. .setSmallIcon(R.mipmap.ic_cds_launcher)
  7. .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_cds_launcher))
  8. .setLights(Color.BLUE, 2000, 1000)
  9. .setAutoCancel(true);
  10. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  11. builder.setVisibility(Notification.VISIBILITY_PUBLIC);
  12. // 关联PendingIntent
  13. builder.setFullScreenIntent(intent, false);// 悬挂式横幅提示
  14. }
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/575671
推荐阅读
相关标签
  

闽ICP备14008679号