2017-02-11 2 views
1

에서 finish()를 호출하면 최근 응용 프로그램 목록에서 응용 프로그램 제외 백그라운드에서 서비스를 실행하고 특정 기간에 알림을 사용하여 알림을 만들고 사용자가 알림을 클릭하면 Activity (SurveyForm)). 사용자가 버튼을 누르고 백그라운드 서비스를 계속 실행하면 해당 활동을 닫고 싶습니다. Activity 내에서 finish() 메서드를 호출하고 있지만 완전히 닫히지 않고 응용 프로그램이 최근 응용 프로그램 목록에 계속 남아 있습니다.Activity

알림을 생성하는 코드입니다.

Intent notificationIntent = new Intent(this, SurveyForm.class); 
    notificationIntent.setAction(Constants.SURVEY_ACTION); 

    PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); 

    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
    Notification notification = new NotificationCompat.Builder(this) 
      .setContentTitle("Survey") 
      .setTicker("New Survey") 
      .setContentText("Please, answer the survey.") 
      .setSmallIcon(R.drawable.survey_notification_icon) 
      .setSound(alarmSound) 
      .setLights(0xff00ff00, 1000, 1000) 
      .setContentIntent(resultPendingIntent) 
      .setOngoing(true) 
      .build(); 
    notification.defaults = Notification.DEFAULT_VIBRATE; 

    mNotificationManager.notify(Constants.SURVEY_NOTIFICATION_ID, notification); 

그리고 버튼 코드는 다음과 같습니다 :

bSave.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
      //Close the notification 
      nm.cancel(Constants.SURVEY_NOTIFICATION_ID); 

      //Close this Activity 
      finish(); 
     } 
    }); 

업데이트 나 해당 활동에 대한 매니페스트 파일의 다음 속성을 지정하여 문제를 해결 한

.

안드로이드 : excludeFromRecents는 = "true"로

내가 해당 활동에 대한 매니페스트 파일에 excludeFromRecents 속성을 지정하여 문제를 해결 한
+1

당신이 "최소화"무엇을 의미합니까? Android는 앱을 "최소화"하는 개념이 없습니다. – Karakuri

+1

@Karakuri는 응용 프로그램이 숨겨져 있지만 최근 응용 프로그램 목록에 여전히 나타남을 의미합니다. – Enrique

+0

@Enrique, 해결책을 질문에 대한 답변으로 게시 한 다음 동의하십시오. 그것은 다른 사람들을 더 잘 돕고 포인트를 얻게 해줄 것입니다. –

답변

2

.

안드로이드 : excludeFromRecents = "true"를