【问题标题】:Nexus 7 tablet not showing notification actionsNexus 7 平板电脑不显示通知操作
【发布时间】:2018-03-09 12:22:43
【问题描述】:

我正在尝试在装有 Android 6.0.1 的 Nexus 7 上显示通知操作,但没有显示。是因为操作系统吗?我已经测试了带有 Android 7.0 的 S6 edge,它看起来很完美。

NotificationCompat.Builder(this, resources.getString(R.string.default_notification_channel_id))
            .setSmallIcon(R.mipmap.ic_launcher_round)
            .setContentIntent(pIntent)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .addAction(NotificationCompat.Action(R.mipmap.ic_launcher, resources.getString(R.string.confirm_action_notification), yesPendingIntent))
            .addAction(NotificationCompat.Action(R.mipmap.ic_launcher, resources.getString(R.string.deny_action_notification), noPendingIntent))
            .setPriority(PRIORITY_MAX)
            .setDefaults(Notification.DEFAULT_VIBRATE)
            .setCustomHeadsUpContentView(headsUpView)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setCustomContentView(collapsedView)
            .setCustomBigContentView(expandedView)
            .setStyle(NotificationCompat.DecoratedCustomViewStyle())
            .setPublicVersion(privateNotification)
            .build()

【问题讨论】:

    标签: android android-notifications notification-action


    【解决方案1】:

    你能试试下面的代码吗:

    Notification n = new Notification.Builder(context)
                .setContentTitle(violationHeader)
                .setContentText(message)
                .setSmallIcon(R.drawable.login_logo)
                .setContentIntent(pIntent)
                .setAutoCancel(true)
                .setSound(uri)
                .setVibrate(new long[]{10, 40, 100, 200, 10})
                .build();
        NotificationManager notificationManager =
                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(notificationId, n);
    

    【讨论】:

    • 谢谢,但这并不能解决问题。您的解决方案甚至没有添加操作。
    • 谢谢,但这不是一个解决方案,因为不幸的是 Nexus 7 运行 Marshmallow。我无法使用 API 通知和通知操作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-24
    • 1970-01-01
    相关资源
    最近更新 更多