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

Startforeground에서 notification X(cancel) 문의

0 추천
@Override
 public int onStartCommand(Intent intent, int flags, int startId) {

Intent notificationIntent = new Intent(this, Servicecancel.class);
PendingIntent contextIntext = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

  Notification notification = new Notification(R.drawable.ic_launcher,"서비스 실행중",System.currentTimeMillis());
  notification.setLatestEventInfo(getApplicationContext(), "어플", "불루투스 실행중", null);
  startForeground(NOTIFICATION_ID, notification);
  return Service.START_REDELIVER_INTENT;
 }

Notification에서 취소버튼을 클릭시 앱을 종료하고 싶은데

현재까지는 이렇게 구성했습니다. 여기서 어떻게 추가를 해야할지 몰라서 이렇게 올립니다.
쿠쿠부다스 (6,470 포인트) 님이 2016년 1월 11일 질문
해결하셨나요? 저도 같은 부분 구현중인데 잘안되네욥 :(

1개의 답변

0 추천

x버튼이 저런형태로도 나오던가요?

음 기억엔 remoteView 로 레이아웃 만들고 notification에 연결해야 됐던걸로 기억하는데요.

setOnClickPendingIntent 이걸로 연결하시면 될텐데요..

앱 종료라... 시나리오는 모르겠으나 runningProcess 구해서 있으면 종료 시키면 될려나요...

귀찮근 (2,960 포인트) 님이 2016년 1월 12일 답변
...