본문 바로가기
개발자/Android

[Android] Notification 알림을 상단바는 표시되지 않게 하려면?

by Alex.K 2015. 10. 5.
반응형

저는 안드로이드를 OS Ver 2.2 부터 지원하는 앱을 만들기 때문에 Notification 같은 경우에도


NotificationCompat 를 사용해서 알림을 표시합니다.


Ongoing 알림 같은 경우에는 계속 표시가 되어있어야하기 때문에 상단바나 잠금화면에서 알림이 표시되지 않았으면 하는 바램이 있었는데요.


해당 부분에 대해 이제야 찾았네요~!


해결방안

 NotificationCompat.Builder -> setPriority(NotificationCompat.PRIORITY_MIN);


위의 우선순위(Priority)를 Min(-2)로 사용하게 되면 알림영역에는 알림을 표시하고 있지만, 상단바나 잠금화면에서는 알림을 표시하지 않습니다.


레퍼런스 사이트에는 이렇게 적혀 있네요.


Set the relative priority for this notification. Priority is an indication of how much of the user's valuable attention should be consumed by this notification. Low-priority notifications may be hidden from the user in certain situations, while the user might be interrupted for a higher-priority notification. The system sets a notification's priority based on various factors including the setPriority value. The effect may differ slightly on different platforms.

반응형

댓글