Remoteview 未在后台应用
Remoteview is not applied in background
我已将 Remoteview 应用于通知。当用户在前台时它有效,但当用户在后台时,通知不会显示为 remoteview。
如何在用户处于后台时应用远程视图?
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.doggy_downgrade3)
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
.setContentTitle("Doggy")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setNumber(1)
.setPriority(Notification.PRIORITY_MAX)
.setContent(remoteViews)
.setContentIntent(pendingIntent);
以上是我构建通知的代码。
您需要设置两种不同的view,一种是custom content view,一种是Big content view,设置如下-
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(icon)
.setCustomContentView(contentViewSmall)
.setCustomBigContentView(contentViewBig)
.setContentTitle("Custom Notification")
.setContentIntent(contentIntent)
.setAutoCancel(true)
.setWhen(when);
mNotificationManager.notify(1, notificationBuilder.build());
上的博客
我已将 Remoteview 应用于通知。当用户在前台时它有效,但当用户在后台时,通知不会显示为 remoteview。
如何在用户处于后台时应用远程视图?
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.doggy_downgrade3)
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
.setContentTitle("Doggy")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setNumber(1)
.setPriority(Notification.PRIORITY_MAX)
.setContent(remoteViews)
.setContentIntent(pendingIntent);
以上是我构建通知的代码。
您需要设置两种不同的view,一种是custom content view,一种是Big content view,设置如下-
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(icon)
.setCustomContentView(contentViewSmall)
.setCustomBigContentView(contentViewBig)
.setContentTitle("Custom Notification")
.setContentIntent(contentIntent)
.setAutoCancel(true)
.setWhen(when);
mNotificationManager.notify(1, notificationBuilder.build());
上的博客