Android

상태바에 알림 생성

moonwoou 2015. 1. 19. 15:17

상태바에 알림 생성.


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;