2013-04-15 6 views
0

여기에 문제가 있습니다. onPostExecute() 메서드는 모든 작업을 수행하지 않습니다.AsyncTask onPostExecute가 필요한 모든 작업을 수행하지 않습니다.

내 onPostExecute에서 볼 수 있듯이 부울 값은 어떤 일이 발생하는지 결정합니다. 하지만 로그를 통해 b를 얻는다면 아무 것도 볼 수 없으며 실행되는 코드는 b = true의 코드입니다.

대화 상자에 성공적이라고 표시되지만 환경 설정이 표시되지 않습니다. 업데이트, 여기서 내가 뭘 잘못하고 있니? 좋아

@Override 
protected void onPostExecute(Boolean b) { 
    publishProgress(100); 
    dialog.dismiss(); 
    if (b) { 
     e.putInt(Constants.pref_updateweek, cal.get(Calendar.WEEK_OF_YEAR)); 
     e.commit(); 
     AlertDialog.Builder alert = new AlertDialog.Builder(mContext); 

     alert.setTitle("Succes"); 
     alert.setMessage("Alles is bijgewerkt"); 

     alert.setPositiveButton("Ok", null); 

     alert.show(); 
     act.commUI(); 
    } else { 
     AlertDialog.Builder alert = new AlertDialog.Builder(mContext); 

     alert.setTitle("Error"); 
     alert.setMessage("Er is een fout opgetreden."); 

     alert.setPositiveButton("Ok", null); 

     alert.show(); 
    } 
} 
+0

publishProgress (100); doInBackground()에 있어야합니다. AlertDialog.Builder alert = 새로운 AlertDialog.Builder (mContext); 전에 이것을 옮길 수 있습니까? – Raghunandan

+0

전체 AsynTask의 코드를 넣을 수 있습니까? e.commit()이 반환하는 부울을 살펴보십시오 (새 값이 영구 저장소에 성공적으로 기록 된 경우 true를 반환합니다). sharedpreferences 초기화 문제 일 수 있습니다 <-> – AlexBcn

+0

소스가이 [pastebin] (http://pastebin.com/pkdrRGFV)에서 19:17까지 사용 가능합니다 – WHDeveloper

답변

0

내 문제는 내가 e.commit()를 잊었 내 응용 프로그램의 첫 번째 버전에서는 지금

e.putInt(Constants.pref_updateweek, cal.get(Calendar.WEEK_OF_YEAR)); 
e.commit(); 

정말 바보가 된 기분 발견 및 업데이트에 나는 그것을 해결했습니다.

또 다른 클래스에서 동일한 AsyncTask가 있지만 약간 다른 것들을 가지고 있으므로 문제는 코드에서 내 질문에 없었지만 매우 비슷한 코드로되어 있으므로 (예 : e.commit() 제외) 해당 클래스에 이전 코드를 복사했습니다. 다른 클래스지만, 제안에 감사드립니다!

관련 문제