缺少Android 4.0.3通知操作

时间:2014-03-07 12:53:39

标签: android notifications

我正在创建这样的通知:

    NotificationManager notifyManager = (NotificationManager) App
        .getContext().getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(
        App.getContext());
    builder.setSmallIcon(R.drawable.ic_launcher);
    builder.setContentTitle(task.getFileNode().getName());
    Intent cancelIntent = CancelDownloadReceiver
        .getCancelDownloadIntent(ticketUUID);
    PendingIntent intent = PendingIntent.getBroadcast(
        App.getContext(), 0, cancelIntent,
        PendingIntent.FLAG_UPDATE_CURRENT);
    builder.addAction(
        R.drawable.ic_stat_cancel,
        App.getContext().getString(
            R.string.notification_download_cancel),
        intent);
    builder.setProgress(0, 0, true);
    Notification notification = builder.build();
    notification.flags = Notification.FLAG_ONGOING_EVENT;
    notifyManager.notify(ticketUUID, 1, notification);

问题是摩托罗拉XOOM与Android 4.0.3的行动缺失。为什么?如您所见,我正在使用支持库中的类。

1 个答案:

答案 0 :(得分:2)

即使这是在支持库中,它也无法在Android 4.0.x上运行。请参阅documentation:“操作按钮不会出现在Android 4.1之前的平台上。”