<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                > 編寫:[fastcome1985](https://github.com/fastcome1985) - 原文:[http://developer.android.com/training/notify-user/managing.html](http://developer.android.com/training/notify-user/managing.html) 當你需要對同一事件發布多次Notification時,你應該避免每次都生成一個全新的Notification。相反,你應該考慮去更新先前的Notification,或者改變它的值,或者增加一些值,或者兩者同時進行。 下面的章節描述了如何更新Notifications,以及如何移除它們。 ### 改變一個Notification 想要設置一個可以被更新的Notification,需要在發布它的時候調用[NotificationManager.notify(ID, notification)](#))方法為它指定一個notification ID。更新一個已經發布的Notification,需要更新或者創建一個[NotificationCompat.Builder](#)對象,并從這個對象創建一個[Notification](#)對象,然后用與先前一樣的ID去發布這個[Notification](#)。 下面的代碼片段演示了更新一個notification來反映事件發生的次數,它把notification堆積起來,顯示一個總數。 ~~~ mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // Sets an ID for the notification, so it can be updated int notifyID = 1; mNotifyBuilder = new NotificationCompat.Builder(this) .setContentTitle("New Message") .setContentText("You've received new messages.") .setSmallIcon(R.drawable.ic_notify_status) numMessages = 0; // Start of a loop that processes data and then notifies the user ... mNotifyBuilder.setContentText(currentText) .setNumber(++numMessages); // Because the ID remains unchanged, the existing notification is // updated. mNotificationManager.notify( notifyID, mNotifyBuilder.build()); ... ~~~ ### 移除Notification Notifications 將持續可見,除非下面任何一種情況發生。 ~~~ * 用戶清除Notification單獨地或者使用“清除所有”(如果Notification能被清除)。 * 你在創建notification時調用了 setAutoCancel(developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setAutoCancel(boolean))方法,以及用戶點擊了這個notification, * 你為一個指定的 notification ID調用了[cancel()](developer.android.com/reference/android/app/NotificationManager.html#cancel(int))方法。這個方法也會刪除正在進行的notifications。 * 你調用了[cancelAll()](developer.android.com/reference/android/app/NotificationManager.html#cancelAll())方法,它將會移除你先前發布的所有Notification。 ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看