2017-12-29 2 views
1

이것은 내 소스 코드입니다. 삭제할 수 없도록 만들려면 알림 관리자에서 스 와이프하지 말고 삭제해야합니다. 가능한가?삭제 불가능한 알림은 어떻게 만듭니 까?

Intent intent = new Intent(this, SecondActivity.class); intent.putExtra("NotiClick", true); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { 
     Notification Noti; 
     Noti = new Notification.Builder(this) 
       .setContentTitle("Dont Lose It") 
       .setContentText("Stop monitoring by click!") 
       .setSmallIcon(R.mipmap.ic_launcher) 
       .setContentIntent(pIntent) 
       .setAutoCancel(true).build(); 

     NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 

     notificationManager.notify(0, Noti); 
    }` 

답변

1

당신은 당신의 Notification.Builder으로 setOngoing(true)를 사용해야합니다 :

이는 "진행"알림 여부를 설정합니다. 진행중인 알림은 사용자가 해독 할 수 없으므로 애플리케이션이나 서비스가이를 취소해야합니다. 이들은 일반적으로 사용자가 활발하게 참여하고 있거나 (예 : 음악 재생 중) 백그라운드에서 대기 중이거나 기기를 점유하고있는 백그라운드 작업 (예 : 파일 다운로드, 동기화 작업, 활성 네트워크 연결)을 나타내는 데 사용됩니다.

+0

클릭하면 어떻게 삭제할 수 있습니까? 지금은 여전히 ​​삭제할 수 없기 때문에 : -/ – MarekMach

+0

수동으로 취소해야합니다. – ianhanniballake

관련 문제