Exemple #1
0
 private void fetchNotifications() {
   try {
     List<Notification> notifications = NotifiactionAPI.fetchNotifications();
     if (notifications == null) return;
     for (Notification notification : notifications) {
       Intent intent = new Intent(this, MainActivity.class);
       intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
       PendingIntent pendingIntent =
           PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
       MyChatUtility.sendNotification(
           this,
           notification.getNotificationId(),
           "新通知",
           notification.getNotification(),
           pendingIntent);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }