1

I need to obtain a list of top-level Windows from within the Android application for that given application. Is there are a way how to do it?

It is a very similar requirement to a former Hierarchy Viewer or newer Layout Inspector, BUT I have to do it from the app itself. I don't want to fetch that for other application, that should be impossible for security and privacy reasons as correctly commented below.

See screenshot of the list that has been obtained via Layout Inspector. That is exactly the list that I want to get.

enter image description here

Ales Teska
  • 1,198
  • 1
  • 17
  • 38
  • I mean I want to obtain that for my own application. I will reformulate the question. – Ales Teska Jan 01 '17 at 00:28
  • 1
    Have you tried ViewServer: https://github.com/romainguy/ViewServer Also see: http://stackoverflow.com/questions/21263454/how-do-you-include-romainguys-viewserver-in-android-studio-with-gradle – Morrison Chang Jan 01 '17 at 00:58
  • @MorrisonChang - ViewServer doesn't capture PopupWindows. – Ales Teska Jan 01 '17 at 01:14
  • 1
    Not sure if this would work for you: http://stackoverflow.com/a/31697639/295004 – Morrison Chang Jan 01 '17 at 01:18
  • 1
    Found this: http://stackoverflow.com/a/41103060/1640284 - it uses reflections and WindowManagerGlobal and works exactly as expected in this question. I also confirm, that I found WindowManagerGlobal class meanwhile independently in the Android source codes and it contains a private list of Windows within the app. Pity that it is not publicly accessible. – Ales Teska Jan 01 '17 at 11:06
  • @AlesTeska it looks like this only gives the root views in windows, but not actual `Window` objects. Did you end up finding a way to get the real windows? (you can get a Window from an Activity by doing `this.getWindow()`, but I want all the windows). – Aaron Ash Oct 18 '18 at 21:24

0 Answers0