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

노티피케이션 업데이트 방법

0 추천
노티피케이션을 띄우고 시간의 흐름을 표시해주고싶어서 아래와 같이 1초마다 갱신하려고 하니,,

노티피케이션이 갱신은되는데,, 텍스트만 바뀌는게 아니라 노티피케이션 전체가 새로바뀌더군요..

저는 텍스트만 계속 바꿔주고 싶은데 어떻게 해야하나요?

int interval = 0;

CountDownTimer timer = new CountDownTimer(3600 * 1000, 1000) {
  @Override
  public void onTick(long millisUntilFinished) {
    interval++;
    String time = String.format("%02d", (interval/60)%60) + ":" + String.format("%02d", interval%60);
    
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
      .setContentTitle("Notification Update Test")
      .setContentText(time)
      .setTicker("Notification Update Test")

    Notification notification = builder.build();
    notificationManager.notify(8888, notification);
  }

  @Override
  public void onFinish() {
    //
  }
};

timer .start();
익명사용자 님이 2015년 11월 12일 질문

1개의 답변

0 추천
해보지는 않았는데 stackoverflow에 좋은 글이 있어서 소개합니다.

 

http://stackoverflow.com/questions/14885368/update-text-of-notification-not-entire-notification

 

플래그 상태를 정해보시죠.
dante2k (8,390 포인트) 님이 2015년 11월 12일 답변
오 초간단한거였군요, 잘되네요 감사합니다.
...