【问题标题】:On some phones custom notification doesn't have an arrow for collapse/expand在某些手机上,自定义通知没有折叠/展开箭头
【发布时间】:2018-07-26 18:57:04
【问题描述】:

我尝试为我的测试项目创建自定义通知。我有用于折叠/展开视图的 remoteViews。我的简单代码是

public static void send(Context context, RemoteViews collapsedView, RemoteViews expandedView) {
    Notification notification = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
        .setContent(collapsedView)
        .setCustomContentView(collapsedView)
        .setCustomBigContentView(expandedView)
        .setSmallIcon(R.mipmap.ic_launcher)
        .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
        .setOngoing(true)
        .build();

    getNotificationManager(context).notify(0, notification);
}

此代码运行良好,但我意外地注意到,在某些手机(android 6.0)上,当我收到自定义通知时,它没有用于操作折叠/展开的箭头。

你能帮帮我吗?

另外当我发送自定义通知时,我看到: 1)第一个状态是展开,而不是折叠(很奇怪) 2) 没有折叠的动作箭头

【问题讨论】:

  • android 4.1+ 用于扩展,不是吗?我在 android 6.0 上测试
  • 6.0 上没有箭头但是可以展开通知吗?滑动到底部
  • 只是编辑问题)
  • 我尝试用滑动折叠但它不起作用
  • O_o 我可以用两根手指滑动折叠通知。捏滑动

标签: android android-notifications


【解决方案1】:

我将此代码用于我的通知,但我认为 Andorid 6.0 没有这个问题:

Notification notification = new Notification.Builder(MainActivity.this)
                    .setContentTitle("Some title")
                    .setContentText("Some text")
                    .setSmallIcon(R.mipmap.ic_launcher_round)
                    .setSound(uriSound)
                    .setVibrate(new long[]{0, 100, 20, 100})
                    .setShowWhen(true)
                    .setContentIntent(mainIntent)
                    .setStyle(new Notification.BigTextStyle()
                            .bigText("Some other text"))
                    .setAutoCancel(true)
                    .build();

【讨论】:

  • 是的,它真正的好替代解决方案。我只是想看看RemoteViews的工作
猜你喜欢
  • 2017-10-11
  • 2013-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-10
  • 1970-01-01
  • 2020-11-16
相关资源
最近更新 更多