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

통지에서 눌러면 사라지게 하기...?

0 추천
int icon = R.drawable.ic_stat_gcm;
        long when = System.currentTimeMillis();
        NotificationManager notificationManager = (NotificationManager)
                context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new Notification(icon, message, when);
        String title = context.getString(R.string.app_name);
       
        Intent notificationIntent = new Intent(context, MainActivity.class);
        // set intent so it does not start a new activity
        notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        PendingIntent intent =
                PendingIntent.getActivity(context, 0, notificationIntent, 0);
        notification.setLatestEventInfo(context, title, message, intent);
       
        notification.defaults = Notification.DEFAULT_ALL;
        notificationManager.notify(1, notification);\

 위소스에서 통지가 와서 눌러면 MaiActivity.class로 이동하는데 이동하지 않고 그냥 통지뷰가 사라지게 하고 싶으면 어떻게 하면 되나요?
헨씀히포 (3,660 포인트) 님이 2014년 2월 2일 질문

1개의 답변

+1 추천
int FLAG_AUTO_CANCEL Bit to be bitwise-ored into the flags field that should be set if the notification should be canceled when it is clicked by the user.

 

건방진프로그래머 (26,630 포인트) 님이 2014년 2월 2일 답변
notification.flags |= Notification.FLAG_AUTO_CANCEL;
이렇게 해봤는데 눌러도 사라지지 않습니다
...