Android code all the current app windows.
Android-find all windows in all applications programmatically?
Is it possible to enumerate all current app windows programmatically?
Dialog box, for example, all will be opened in a new window, independent of the main activity window. I can find them through Dialog. getWindow, but I don't know how to do this with a built-in component, for example, in the activity menu pop-up.
Is there any way to enumerate all windows associated with my application from the application context, window manager, or something else?
I can see all my application windows in the adb dumpsys window, but I am looking for a way to do this in my application without the need of root.
Android View
Best Answer:
I found a way to reflect WindowManagerGlobal. At least so far he has worked well in android-18 .....
private void logRootViews() { try { Class wmgClass = Class.forName(android.view.WindowManagerGlobal); Object wmgInstnace = wmgClass.getMethod(getInstance).invoke(null, (Object[])null); Method getViewRootNames = wmgClass.getMethod(getViewRootNames); Method getRootView = wmgClass.getMethod(getRootView, String.class); String[] rootViewNames = (String[])getViewRootNames.invoke(wmgInstnace, (Object[])null); for(String viewName : rootViewNames) { View rootView = (View)getRootView.invoke(wmgInstnace, viewName); Log.i(TAG, Found root view: + viewName + : + rootView); } } catch (Exception e) { e.printStackTrace(); }}
Output:
Found root view: com. example. paintsample/com. example. paintsample. paintSample/android. view. viewRootImpl @ 41deeff0: com. android. internal. policy. impl. phoneWindow $ DecorView {41dcc278 V. E ..... R ....... 0, 0-768,1184}
Found root view: PopupWindow: 42887380/android. view. viewRootImpl @ 42891820: android. widget. popupWindow $ PopupViewContainer {42891450 V. E ............. 0, 0-424,618}