乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      通知未被駁回(Android)

       印度阿三17 2019-07-11

      如果單擊“操作”,則通知setAutoCancel(true)不起作用

      我有一個通知,其中包含一個動作.當我點擊通知時,它會從列表中刪除.但是,當我單擊Action它成功完成Action(即調用)時,但當我返回到通知列表時,它仍然存在.
      AlarmReceiver的相對代碼:

      public class AlarmReceiver extends BroadcastReceiver {
      Meeting meeting;
      
      /**
       * Handle received notifications about meetings that are going to start
       */
      @Override
      public void onReceive(Context context, Intent intent) {
      
          // Get extras from the notification intent
          Bundle extras = intent.getExtras();
          this.meeting = extras.getParcelable("MeetingParcel");
      
          // build notification pending intent to go to the details page when click on the body of the notification
          Intent notificationIntent = new Intent(context, MeetingDetails.class);
          notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          notificationIntent.putExtra("MeetingParcel", meeting);      // send meeting that we received to the MeetingDetails class
          notificationIntent.putExtra("notificationIntent", true);    // flag to know where the details screen is opening from
      
          PendingIntent pIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
      
          // build intents for the call now button
          Intent phoneCall = Call._callIntent(meeting);
          if (phoneCall != null) {
      
              PendingIntent phoneCallIntent = PendingIntent.getActivity(context, 0, phoneCall, PendingIntent.FLAG_CANCEL_CURRENT);
      
              int flags = Notification.FLAG_AUTO_CANCEL;
      
              // build notification object
              NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
              Notification notification = builder.setContentTitle("Call In")
                      .setContentText(intent.getStringExtra("contextText"))
                      .setTicker("Call In Notification")
                      .setColor(ContextCompat.getColor(context, R.color.colorBluePrimary))
                      .setAutoCancel(true)                    // will remove notification from the status bar once is clicked
                      .setDefaults(Notification.DEFAULT_ALL)  // Default vibration, default sound, default LED: requires VIBRATE permission
                      .setSmallIcon(R.drawable.icon_notifications)
                      .setStyle(new NotificationCompat.BigTextStyle()
                              .bigText(meeting.description))
                      .addAction(R.drawable.icon_device, "Call Now", phoneCallIntent)
                      .setCategory(Notification.CATEGORY_EVENT)   // handle notification as a calendar event
                      .setPriority(Notification.PRIORITY_HIGH)    // this will show the notification floating. Priority is high because it is a time sensitive notification
                      .setContentIntent(pIntent).build();
      
              notification.flags = flags;
      
              // tell the notification manager to notify the user with our custom notification
              NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
              notificationManager.notify(0, notification);
          }
        }
      }
      

      enter image description here

      解決方法:

      我今天遇到了這個問題,發(fā)現(xiàn)FLAG_AUTO_CANCEL和setAutoCanel(true)都在點擊通知時起作用,
      但不適合行動點擊

      簡單地說,在目標服務或行動活動中,取消通知

      NotificationManager manager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
      manager.cancelAll();
      

      或者如果有更多通知

      manager.cancel(notificationId);
      
      來源:https://www./content-4-316951.html

        本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多