如何增加NotificationCompat显示的时间

时间:2016-05-05 15:28:03

标签: android notifications

我正在使用NotificationCompat来显示来电,但问题是时间限制较少,我想显示NotificationCompat 40秒,有没有办法增加显示通知的时间,因为显示通知的当前时间小于40秒

    Intent dismissIntent = new Intent();
    PendingIntent piDismiss = PendingIntent.getService(ctx, 0,dismissIntent, 0);
    Intent callIntent = new Intent();
    PendingIntent pendingcall = PendingIntent.getService(ctx, 0, callIntent, 0);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx).setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle("Ping Notification").setContentText("Tomorrow will be your birthday.")
            .setDefaults(Notification.DEFAULT_ALL).setPriority(NotificationCompat.PRIORITY_HIGH)
            .addAction(R.drawable.call_end, "Dismiss", piDismiss)
            .addAction(R.drawable.call_accept, "Accept", pendingcall);

    NotificationManager notificationManager = (NotificationManager) ctx
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, builder.build());

由于

1 个答案:

答案 0 :(得分:2)

在操作系统中设置了抬头通知可见性长度,无法更改