Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is this window leak happening?
    text
    copied!<p>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.</p> <p>Here's the logcat of the error:</p> <pre><code>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.&lt;init&gt;(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) </code></pre> <p>Why exactly is this happening? What can I do to get rid of this error? Happy to provide further code as needed. Thanks.</p> <p>EDIT - here is the code of the problematic AsyncTask:</p> <pre><code> @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&lt;String, Object&gt; restaurant : resp.getData()) { //..a bunch of JSON parsing.. dialog.dismiss(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload