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

时间:2012-02-28 17:27:34

标签: android notifications push-notification android-4.0-ice-cream-sandwich

仅在Android 4.x中出现。

我们在后台通过应用程序发出通知: - 经过一段时间后,通知消失;当这个ocurrs 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);

发现更多数据,只有当应用后台服务关闭时才会出现,如果我不关闭服务通知则不会消失。

0 个答案:

没有答案