Android 4.x问题:通知在一段时间后消失

Android 4.x问题:通知在一段时间后消失,android,notifications,push-notification,android-4.0-ice-cream-sandwich,Android,Notifications,Push Notification,Android 4.0 Ice Cream Sandwich,仅在Android 4.x中出现 我们在后台使用应用程序发出通知:-当一段时间过去后,通知消失;当出现这种情况时,logcat看起来是这样的: 02-28 18:12:27.711: I/RegisteredComponentCache(464): ComponentInfo: ResolveInfo{41884668 com.android.apps.tag.TagViewer p=0 o=0 m=0x108000}, techs: android.nfc.tech.Ndef, 02

仅在Android 4.x中出现

我们在后台使用应用程序发出通知:-当一段时间过去后,通知消失;当出现这种情况时,logcat看起来是这样的:

02-28 18:12:27.711: I/RegisteredComponentCache(464): ComponentInfo: ResolveInfo{41884668 com.android.apps.tag.TagViewer p=0 o=0 m=0x108000}, techs: android.nfc.tech.Ndef, 
    02-28 18:12:27.711: D/PackageManager(206): generateServicesMap(android.accounts.AccountAuthenticator): 7 services unchanged
    02-28 18:12:27.719: D/AccountTypeManager(5786): Registering external account type=com.lopez, packageName=com.lopez
    02-28 18:12:27.719: D/AccountTypeManager(5786): Registering external account type=com.whatsapp, packageName=com.whatsapp
    02-28 18:12:27.726: W/ResourceType(5786): getEntry failing because entryIndex 598 is beyond type entryCount 195
    02-28 18:12:27.726: W/ResourceType(5786): Failure getting entry for 0x7f020256 (t=1 e=598) in package 0 (error -2147483647)
    02-28 18:12:27.726: D/AccountTypeManager(5786): Registering external account type=com.twitter.android.auth.login, packageName=com.twitter.android
    02-28 18:12:27.758: D/PackageManager(206): generateServicesMap(android.content.SyncAdapter): 18 services unchanged
    02-28 18:12:27.765: I/AudioService(206):  AudioFocus  abandonAudioFocus() from android.media.AudioManager@41a65ca8
    02-28 18:12:27.851: W/ResourceType(5786): getEntry failing because entryIndex 206 is beyond type entryCount 195
    02-28 18:12:27.859: W/ResourceType(5786): Failure getting entry for 0x7f0200ce (t=1 e=206) in package 0 (error -2147483647)
    02-28 18:12:27.859: D/AccountTypeManager(5786): Registering external account type=com.facebook.auth.login, packageName=com.facebook.katana
    02-28 18:12:27.867: W/ResourceType(5786): getEntry failing because entryIndex 280 is beyond type entryCount 195
    02-28 18:12:27.867: W/ResourceType(5786): Failure getting entry for 0x7f020118 (t=1 e=280) in package 0 (error -2147483647)
    02-28 18:12:27.867: D/AccountTypeManager(5786): Registering 1 extension packages
    02-28 18:12:27.875: E/ExternalAccountType(5786): Unsupported attribute readOnly
    02-28 18:12:27.875: W/ResourceType(5786): getEntry failing because entryIndex 207 is beyond type entryCount 195
    02-28 18:12:27.875: W/ResourceType(5786): Failure getting entry for 0x7f0200cf (t=1 e=207) in package 0 (error -2147483647)
    02-28 18:12:27.883: D/AccountTypeManager(5786): Registering extension package account type=com.google, dataSet=plus, packageName=com.google.android.apps.plus
    02-28 18:12:27.883: I/AccountTypeManager(5786): Loaded meta-data for 7 account types, 7 accounts in 167ms(wall) 14ms(cpu)
    02-28 18:12:28.047: D/dalvikvm(22579): GC_FOR_ALLOC freed 2150K, 39% free 20337K/32967K, paused 24ms
    02-28 18:12:28.492: D/dalvikvm(22579): GC_CONCURRENT freed 2628K, 41% free 19699K/32967K, paused 2ms+4ms
    02-28 18:12:28.804: D/dalvikvm(22579): GC_CONCURRENT freed 1060K, 38% free 20513K/32967K, paused 2ms+5ms
该应用程序在后台有一个服务,当任务完成时,该服务将自动关闭。显示通知的代码为:

int icon = R.drawable.notification;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, title, when);
notification.flags |= Notification.FLAG_ONGOING_EVENT; notification.flags &= ~Notification.FLAG_NO_CLEAR; notification.flags &= ~Notification.FLAG_AUTO_CANCEL;
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify("Lopez",notificationId, notification);
更多的数据发现,只有当应用程序后台服务关闭时才出现OCURR,如果我不关闭服务,通知不会消失