繁体   English   中英

通知动画,仅在Galaxy nexus上

[英]Notification animation, only on Galaxy nexus

我有一个前台服务,其中有一条通知,我会每秒更新一次作为计时器。 这在我的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());
}   

这是另一个在通知栏中运行的应用程序,它是一种服务,可以起到这种作用。 卸载该应用程序后有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM