如何使收件箱样式通知在展开后再次变小




当你向下滑动一个通知时,我会用它来添加文本,该通知会使用timertask每分钟刷新一次。

    final NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.setBigContentTitle("Expanded Details");
    inboxStyle.addLine("• Get fruits.");
    Timer updateTimer = new Timer();
        updateTimer.schedule(new TimerTask()
        {
            public void run()
            {
                try
                {
                    SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss", Locale.GERMANY);
                    String curTime = format.format(new Date());
                    Date Date1 = format.parse(curTime);
                    Date Date2 = format.parse("23.08.2015 23:55:00");
                    long mills = Date1.getTime() - Date2.getTime();
                    int Hours = (int) ((mills / (1000*60*60)) % 24);
                    int Mins = (int) (mills / (1000 * 60)) % 60;
                    int Days = (int) (mills / (1000 * 60 * 60 * 24));
                    String diff = Days * -1 + " days, " + Hours * -1 + " hours and " + Mins * -1 + " minutes";
                    txtCurrentTime = diff;
                    mNotifyBuilder.setContentTitle(txtCurrentTime);
                    mNotifyBuilder.setContentText("until the time runs out.");
                    mNotifyBuilder.setStyle(inboxStyle);
                    mNotificationManager.notify(
                            notifyID,
                            mNotifyBuilder.build());
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
        }, 0, 60000);

问题是,当你向下滑动小通知("直到时间耗尽")以查看扩展的详细信息时,你无法返回小通知,需要重新启动应用程序。到目前为止,您只能在按住通知时查看展开的详细信息

有没有办法让这个触发?就像我向下滑动时,它会像往常一样保持向下,但我可以再次向上移动以获得我的小通知。

尝试使用tickerTextsummarytext

请参阅如何使用android 使用通知收件箱样式

相关内容

最新更新