title: Is there any way to get root view of an activity from a service?
body: <p>I am working on an app in which I have to get all the views of the top most activity. This activity may or <strong>may not</strong> be of my app.
  I am able to get all the views from a <code>ViewGroup(root view)</code>.
  Now I just want to get the root view of top most activity to do my work but I was not able to find any answers which gives me an idea to <strong>get root view</strong> of an activity <strong>from service</strong>.</p>
  
  <p>I had used these methods:</p>
  
  <pre><code>View rootView = Window.DecorView.RootView;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Context ctx = this;
  ViewGroup rootView = ((Activity)ctx).getWindow().getDecorView().findViewById(android.R.id.content);
  </code></pre>
  
  <p>But nothing works inside service class.
  It reports that <code>getWindow()</code> and <code>findViewById</code>() did not work inside android <strong>service class.</strong>
  So I just want to know is there any other way to do the same?
  Thanks In Advance...:-)  </p>