Notification
Posted lin513
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Notification相关的知识,希望对你有一定的参考价值。
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O)
NotificationChannel channel = new NotificationChannel("leo", "测试通知", NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
Intent intent = new Intent(this, NotificationActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
leo = new NotificationCompat.Builder(this, "leo")
.setContentTitle("官方通知")
.setContentText("世界这么大,想去走走吗")
.setSmallIcon(R.drawable.baseline_person_24)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ceshi))
.setColor(Color.parseColor("#ff0000"))
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.build();
以上是关于Notification的主要内容,如果未能解决你的问题,请参考以下文章