我有一个xamarin android推送通知,但当我在某些设备中收到通知时,它会保持打开状态(矩形不会自动关闭),而在其他设备中(ej Samsumg Galaxy A5),通知会自动打开(在不接触它的情况下触发其意图的活动),在其他设备中,通知工作正常。
下面是创建通知的代码
//Create notification
var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;
// Create a PendingIntent; we're only using one PendingIntent (ID = 0):
var notificationId = NotificationCount;
const int pendingIntentId = 0;
intent.SetAction(DateTime.Now.Ticks.ToString());
intent.AddFlags(ActivityFlags.ClearTop);
PendingIntent pendingIntent = PendingIntent.GetActivity(this, notificationId, intent, PendingIntentFlags.UpdateCurrent);
// Instantiate the builder and set notification elements:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.SetContentTitle(title)
.SetAutoCancel(true)
.SetContentIntent(pendingIntent).SetAutoCancel(true)
.SetContentText(payload.Message)
.SetSmallIcon(Resource.Drawable.iconToolbarNotification)
.SetLargeIcon(BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.IconToolbar_blue))
.SetDefaults((int)NotificationDefaults.All)
.SetStyle(new NotificationCompat.BigTextStyle().BigText(payload.Message));
var fullScreenPendingIntent = PendingIntent.GetActivity(this, notificationId, intent, PendingIntentFlags.UpdateCurrent);
builder.SetFullScreenIntent(fullScreenPendingIntent, true);
Settings.NotificationBellAlert = true;
// Build the notification:
Notification notification = builder.Build();
// Publish the notification:
notificationManager.Notify(notificationId, notification);
2条答案
按热度按时间wgx48brx1#
将
PendingIntentFlags.UpdateCurrent
更改为PendingIntentFlags.OneShot
ekqde3dh2#
问题是这段代码
感谢post