2013-12-09 2 views
0

사진을 찍고 오래 처리하는 앱을 개발 중입니다. I는해서 ProgressDialog 통해 상태를 표시하고 싶은 처리 중에, 따라서 I는ProgressDialog가 세로 모드에서만 창 오류를 유출했습니다.

아래와 같이

private class ResultTask extends AsyncTask<multiCrop, String, String> { 

    @Override 
    protected void onPreExecute() { 
     super.onPreExecute(); 
     progressDialog = new ProgressDialog(MainActivity.this); 
     progressDialog.setTitle("Analyzing, please wait ..."); 
     progressDialog.setMessage("Loading.."); 
     progressDialog.setCancelable(false); 
     progressDialog.show(); 
    } 

    @Override 
    protected String doInBackground(multiCrop... mcImgV) { 
     String result = null; 
     //Long processing that uses view multiCrop and occasional publishProgress() calls, returns String result 
    } 

    @Override 
    protected void onProgressUpdate(String... str) { 
     // TODO Auto-generated method stub 
     super.onProgressUpdate(str); 
     progressDialog.setMessage(str[0]); 
    } 

    @Override 
    protected void onPostExecute(String result) { 
     super.onPostExecute(result); 
     ((TextView)findViewById(R.id.resultText)).append(result); 
     progressDialog.dismiss(); 
    } 

} 

ResultTask의 인스턴스는 뷰의 버튼 중 하나의 OnClick 핸들러 생성을 다음과 같이 AsyncTask를 클래스 확장 장치가 풍경에있을 때

public void onResultClick(View v){ 
    ResultTask task = new ResultTask(); 
    task.execute(babyImageView); 
} 

코드는 아무 문제없이 작동하지만 onResultClick 이벤트가 세로 모드에서 트리거되는 경우 나는 MainActivity가 LeakedWindow을 가지고 없다는 오류가 발생합니다. 여기에 무엇이 누락 되었습니까?

* 오류가

12-09 21:34:57.080: E/WindowManager(15365):  Activity com.example.jaundicedetect.MainActivity has leaked window [email protected] that was originally added here 
12-09 21:34:57.080: E/WindowManager(15365):  android.view.WindowLeaked: Activity com.example.jaundicedetect.MainActivity has leaked window [email protected] that was originally added here 
12-09 21:34:57.080: E/WindowManager(15365):  at android.view.ViewRootImpl.<init>(ViewRootImpl.java:350) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:267) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.view.Window$LocalWindowManager.addView(Window.java:537) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.app.Dialog.show(Dialog.java:286) 
12-09 21:34:57.080: E/WindowManager(15365):  at com.example.jaundicedetect.MainActivity$ResultTask.onPreExecute(MainActivity.java:328) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.os.AsyncTask.execute(AsyncTask.java:511) 
12-09 21:34:57.080: E/WindowManager(15365):  at com.example.jaundicedetect.MainActivity.onResultClick(MainActivity.java:524) 
12-09 21:34:57.080: E/WindowManager(15365):  at java.lang.reflect.Method.invokeNative(Native Method) 
12-09 21:34:57.080: E/WindowManager(15365):  at java.lang.reflect.Method.invoke(Method.java:511) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.view.View$1.onClick(View.java:3039) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.view.View.performClick(View.java:3511) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.view.View$PerformClick.run(View.java:14110) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.os.Handler.handleCallback(Handler.java:605) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.os.Handler.dispatchMessage(Handler.java:92) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.os.Looper.loop(Looper.java:137) 
12-09 21:34:57.080: E/WindowManager(15365):  at android.app.ActivityThread.main(ActivityThread.java:4447) 
12-09 21:34:57.080: E/WindowManager(15365):  at java.lang.reflect.Method.invokeNative(Native Method) 
12-09 21:34:57.080: E/WindowManager(15365):  at java.lang.reflect.Method.invoke(Method.java:511) 
12-09 21:34:57.080: E/WindowManager(15365):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
12-09 21:34:57.080: E/WindowManager(15365):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
12-09 21:34:57.080: E/WindowManager(15365):  at dalvik.system.NativeStart.main(Native Method) 
+1

logcat에서 오류를 게시하십시오. –

+0

희망 이것은 'http : // stackoverflow.com/questions/1111980/진행 방법 - 대화 상자 및 배경 - thre' 화면의 방향 전환 - 변경에 도움이 될 것입니다. –

+0

전체 로그보기 –

답변

0

이 시도 발생하면

로그 캣이 어떤 방향 변경을가없는 경우에도이 오류가 발생주의하시기 바랍니다 -

protected void onPostExecute(String result) { 
      super.onPostExecute(result); 
    progressDialog.dismiss(); 

    ((TextView)findViewById(R.id.resultText)).append(result); 
     } 
+0

여전히 문제가 지속됩니다. – jMathew

0

우선 시도 UI 스레드 내에서 진행 대화 상자를 사용하십시오.

 public class LoginScreen extends FragmentActivity { 
     ProgressDialog progressDialog; 


     @Override 
     protected void onCreate(Bundle arg0) { 
      // TODO Auto-generated method stub 
      super.onCreate(arg0); 
      requestWindowFeature(Window.FEATURE_NO_TITLE); 

       setContentView(R.layout.activity_login); 
    progressDialog = ProgressDialog.show(
               LoginScreen.this, null, 
               "Logging you in..."); 
             progressDialog.setCancelable(false); 
    } 
public void progressDialogDismiss() { 
     LoginScreen.this.runOnUiThread(new Runnable() { 
      @Override 
      public void run() { 
       if (progressDialog.isShowing()) 
        progressDialog.dismiss(); 
      } 
     }); 
    } 
    } 

이렇게 사용하십시오. util 클래스를 사용하십시오.

0

죄송합니다. 분명히 ResultTask 인스턴스 직전의 몇 줄에 오류가 있습니다. 뷰의 경계를 벗어난 멀티 크로보기에서 비트 맵을 추출하고있었습니다.

의견을 보내 주셔서 감사합니다.

관련 문제