通知动画,仅适用于Galaxy nexus

时间:2012-10-03 20:56:57

标签: android notifications galaxy foreground

我有一个前台服务,其中包含我每秒更新一次作为计时器的通知。这在我的Android 4.1模拟器上工作正常。在Galaxy Nexus手机上,通知会在每次更新时显示为带有动画的新通知。这是为什么?相同的Android版本,但我只在Galaxy Nexus上发现了这种行为。

private void postNotification(Context context, int notificationId, String title, String text, String ticker, boolean service) {
    Intent intent = new Intent(context, MyActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);        
    PendingIntent contentIntent = PendingIntent.getActivity(context, notificationId, intent, 0);

    @SuppressWarnings("static-access")
    NotificationManager nm = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setContentTitle(title);
    builder.setContentText(text);
    if(ticker.length() > 0)
        builder.setTicker(ticker);      
    builder.setSmallIcon(R.drawable.notification);
    builder.setContentIntent(contentIntent);
    builder.setOngoing(service);

    nm.notify(null, notificationId, builder.getNotification()); 
    startForeground(notificationId, builder.getNotification());
}   

1 个答案:

答案 0 :(得分:0)

这是另一个在通知栏中运行的应用程序,作为发生此行为的服务。在卸载该应用程序后工作。