我正在使用这段代码发送本地通知。
然而,如果手机屏幕被滑动锁定,它们会显示在状态栏上。我想像WhatsApp、Facebook、短信等应用一样,在屏幕顶部显示推送通知。如何实现这一点?
mNotificationManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
i, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher))
.setContentTitle(title)
.setDefaults(Notification.DEFAULT_SOUND)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify((int)value, mBuilder.build());
然而,如果手机屏幕被滑动锁定,它们会显示在状态栏上。我想像WhatsApp、Facebook、短信等应用一样,在屏幕顶部显示推送通知。如何实现这一点?