title: Using window in not Activity class?
body: <p>Before,I saw this snippet to find <code>Height of statusbar?(and also Tiltebar)</code> <a href="https://stackoverflow.com/a/3356263/1043882">here</a>:</p>
  
  <pre><code>Rect rectgle= new Rect();
  Window window= getWindow();
  window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
  int StatusBarHeight= rectgle.top;
  int contentViewTop= 
      window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
  int TitleBarHeight= contentViewTop - StatusBarHeight;
  </code></pre>
  
  <p>Yesterday,I tried to use this snippet in an <code>AsyncTask</code> class.So I send instance of my Activity to <code>AsyncTask</code> class,in <code>onCreate</code> of Activity:</p>
  
  <pre><code>LongOperation loper = new LongOperation(this, vg, vArray, hintsArray,x_positionArray, y_positionArray);//Here `this` refers to current Activity
  loper.execute("YES");
  </code></pre>
  
  <p>In doInBackground of AsynkTask class I only did:</p>
  
  <pre><code>Thread.sleep(3000); 
  </code></pre>
  
  <p>And in <code>onPostExecute</code> method I copy above code to calculate height of statusbar and titlebar.But App crashes,without any useful log in logcat.Then I comment some lines like this:</p>
  
  <pre><code>Rect rectgle = new Rect();
      Window window = activity.getWindow();
  //  window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
  //  int StatusBarHeight= rectgle.top;
      contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT)
              .getTop();
  //  int TitleBarHeight= contentViewTop - StatusBarHeight;
  </code></pre>
  
  <p>and App works fine.So it seems that </p>
  
  <blockquote>
    <p>window.getDecorView().getWindowVisibleDisplayFrame(rectgle);</p>
  </blockquote>
  
  <p>causes App crashing,But I do not know why?Did I do some thing incorrect?</p>