I have an app that returns search results. From the list of results, a specific item can be clicked and then a detail page appears. I am getting the following window leak error whenever I make a search and return the results, view a specific result's detail, go back to the list of results, and then click another to see the details. The error comes when I click the second result and the detail page is loading.
Here's the logcat of the error:
11-17 21:32:47.876: E/WindowManager(5945): Activity com.tforan.blobtag4.PlaceActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40707298 that was originally added here
11-17 21:32:47.876: E/WindowManager(5945): android.view.WindowLeaked: Activity com.tforan.blobtag4.PlaceActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40707298 that was originally added here
11-17 21:32:47.876: E/WindowManager(5945): at android.view.ViewRoot.<init>(ViewRoot.java:278)
11-17 21:32:47.876: E/WindowManager(5945): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
11-17 21:32:47.876: E/WindowManager(5945): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
11-17 21:32:47.876: E/WindowManager(5945): at android.view.Window$LocalWindowManager.addView(Window.java:433)
11-17 21:32:47.876: E/WindowManager(5945): at android.app.Dialog.show(Dialog.java:265)
11-17 21:32:47.876: E/WindowManager(5945): at com.tforan.blobtag4.PlaceActivity$FactualRetrievalTask.onPreExecute(PlaceActivity.java:703)
11-17 21:32:47.876: E/WindowManager(5945): at android.os.AsyncTask.execute(AsyncTask.java:391)
11-17 21:32:47.876: E/WindowManager(5945): at com.tforan.blobtag4.PlaceActivity.factualQuery(PlaceActivity.java:295)
11-17 21:32:47.876: E/WindowManager(5945): at com.tforan.blobtag4.PlaceActivity.onCreate(PlaceActivity.java:217)
11-17 21:32:47.876: E/WindowManager(5945): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
11-17 21:32:47.876: E/WindowManager(5945): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
11-17 21:32:47.876: E/WindowManager(5945): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1873)
11-17 21:32:47.876: E/WindowManager(5945): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
11-17 21:32:47.876: E/WindowManager(5945): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
11-17 21:32:47.876: E/WindowManager(5945): at android.os.Handler.dispatchMessage(Handler.java:99)
11-17 21:32:47.876: E/WindowManager(5945): at android.os.Looper.loop(Looper.java:150)
11-17 21:32:47.876: E/WindowManager(5945): at android.app.ActivityThread.main(ActivityThread.java:4358)
11-17 21:32:47.876: E/WindowManager(5945): at java.lang.reflect.Method.invokeNative(Native Method)
11-17 21:32:47.876: E/WindowManager(5945): at java.lang.reflect.Method.invoke(Method.java:507)
11-17 21:32:47.876: E/WindowManager(5945): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
11-17 21:32:47.876: E/WindowManager(5945): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
11-17 21:32:47.876: E/WindowManager(5945): at dalvik.system.NativeStart.main(Native Method)
Why exactly is this happening? What can I do to get rid of this error? Happy to provide further code as needed. Thanks.
EDIT - here is the code of the problematic AsyncTask:
@Override
protected void onPreExecute() {
super.onPreExecute();
dialog = new ProgressDialog(PlaceActivity.this);
dialog.setMessage("Loading...");
dialog.setIndeterminate(true);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(true);
dialog.show();
}
@Override
protected RowResponse doInBackground(RowQuery... query) {
RowResponse resp = factual.fetchRow("restaurants", id, query[0]);
return resp;
}
@Override
protected void onProgressUpdate(Integer... progress) {
}
@Override
protected void onPostExecute(RowResponse resp) {
StringBuffer sb = new StringBuffer();
String today = findCurrentDay(currentDay);
JSONArray todayHours = null;
Log.i("factual response", resp.toString());
for (Map<String, Object> restaurant : resp.getData()) {
//..a bunch of JSON parsing..
dialog.dismiss();
}