마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

nofitication 수정은 못하나요?

0 추천
nofitication 이 이미 있는 상황에서 새로 nofitication 이 추가될때 아래에 추가생성이 계속되는데 추가생성이 되는게 아니라

기존에 있던게 바뀌게 하고 싶어여 지우고 띄우는 방법밖에 없을까요?

 

요약 : nofitication 이 이미 띄워진 상황이면 새로추가 안하고 안에있는 내용만 수정하길 원합니다.
nofitication 님이 2015년 3월 10일 질문
2015년 3월 10일 수정

2개의 답변

0 추천
 
채택된 답변

notification 등록할 떄 id라는게 있을 겁니다.

그 값을 동일하게 주면 내용만 업데이트 됩니다.

아래 API 설명을 읽어보세여 동일한 tag와 id를 가지고 있는 노티가 이미 떠있는 상태에서 cancel 하지 않았다면

그것은 새로운 정보로 업데이트 될 것이다

public void notify (String tag, int id, Notification notification)

Added in API level 5

Post a notification to be shown in the status bar. If a notification with the same tag and id has already been posted by your application and has not yet been canceled, it will be replaced by the updated information.

Parameters
tag A string identifier for this notification. May be null.
id An identifier for this notification. The pair (tag, id) must be unique within your application.
notification A Notification object describing what to show the user. Must not be null.

 

Gradler (109,780 포인트) 님이 2015년 3월 10일 답변
0 추천
notification 이 생성되는 위치를 고정시켜서 하면 될 것 같습니다.

예)

생성 시 -> manager.notify(1, builder.build());

터치 시 ->manager.cancel(1);
taejun (7,240 포인트) 님이 2015년 3월 10일 답변
...