Intent chat=new Intent(this,ChatActivity.class);
chat.putExtra(Constant.Extra.USER_NAME,emMessage.getUserName());
// FLAG_UPDATE_CURRENT : 如果PendingIntent已经存在,保留它并且只替换它的extra数据。
PendingIntent pendingIntent=PendingIntent.getActivity(this, 1, chat, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationManager notificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification=new Notification.Builder(this)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.avatar1))
.setSmallIcon(R.mipmap.ic_contact_selected_2)
.setContentTitle(getString(R.string.receive_new_message))
.setPriority(Notification.PRIORITY_MIN)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.build()
;
notificationManager.notify(1,notification);
通知栏来消息提醒
最新推荐文章于 2021-07-22 13:58:26 发布