본문 바로가기

Android

상태바에 알림 생성

상태바에 알림 생성.


private static final int NOTIFY_ID = 1234;

private void notifyMessage() {
    String notiTitle = this.getString(R.string.app_name);
    String notiContent = this.getString(R.string.msg_notify_content);
    final NotificationManager notiMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Notification noti = new Notification(R.drawable.ic_main, notiTitle, System.currentTimeMillis());
    noti.flags |= Notification.FLAG_NO_CLEAR;

    PendingIntent i = PendingIntent.getActivity(this, 0, new Intent(this, SplashActivity.class), 0);

    noti.setLatestEventInfo(this, notiTitle, notiContent, i);

    notiMgr.notify(NOTIFY_ID, noti);
}


위 코드중에 아래의 코드릴 이래저래 해보면 다양한 결과를 얻을 수 있다.

Notification.FLAG_NO_CLEAR;



'Android' 카테고리의 다른 글

ArrayList 파일로 저장 및 읽기  (0) 2015.03.17
Device별 DPI & 리소스 호출 순서  (0) 2015.02.13
TextView에 Marquee 효과 넣기  (0) 2015.01.07
ImageView의 이미지 교체  (0) 2015.01.07
ProgressBar  (0) 2015.01.05