首页 > 系统 > Android > 正文

android 显示通知栏

2019-11-07 23:35:29
字体:
来源:转载
供稿:网友

NotificationCompat.Builder实现手机自带的显示通知栏 1.可以显示图片(.setSmallIcon(android.R.drawable.ic_lock_idle_alarm);) 2.可以显示文字(.setContentText(“一大波僵尸正在门口”);) 1.可以显示音乐

NotificationCompat.Builder notificationCompat=new NotificationCompat.Builder(this); //设置参数 notificationCompat.setDefaults(NotificationCompat.DEFAULT_ALL); notificationCompat.setContentTitle("提醒"); notificationCompat.setContentText("一大波僵尸正在门口"); notificationCompat.setSmallIcon(android.R.drawable.ic_lock_idle_alarm); Notification notification=notificationCompat.build(); //通知管理器 NotificationManager notificationManager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表