2017-01-01 72 views
0

我試過.setAutoCancel(false) and .setOngoing(true);但是爲什麼我刷卡時我的通知仍然被清除?這裏是我的代碼 -爲什麼我的通知被清除?

 Notification.Builder builder = new Notification.Builder(this) 
      .setSmallIcon(R.drawable.download) 
      .setContentTitle("Download[ROOT]") 
      // .setContentText("This is a test notification") 
      .setAutoCancel(false).setOngoing(true); 
    Intent notificationIntent = new Intent(this, DownloaderRoot.class); 
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, 
      notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); 
    builder.setContentIntent(contentIntent); 
    // Add as notification 
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
    manager.notify(111, builder.build()); 

我已經嘗試添加標記爲良好

// Add as notification 
     NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
     Notification notif = builder.build();// add flag support 
     notif.flags |= Notification.FLAG_ONGOING_EVENT; 
     notif.flags |= Notification.FLAG_NO_CLEAR; 
     manager.notify(111, builder.build()); 
+0

什麼ü意味着刷卡呢??關閉應用程序..? – rafsanahmad007

+0

從狀態欄中滑動 –

回答

0

試試這個

Notification notif = builder.build(); 
notif.flags |= Notification.FLAG_ONGOING_EVENT; 
manager.notify(111, notif); 
+0

請參閱相關編輯 –