사진을 찍고 오래 처리하는 앱을 개발 중입니다. 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)
logcat에서 오류를 게시하십시오. –
희망 이것은 'http : // stackoverflow.com/questions/1111980/진행 방법 - 대화 상자 및 배경 - thre' 화면의 방향 전환 - 변경에 도움이 될 것입니다. –
전체 로그보기 –