Android-Programmatically find all the windows in all applications?
Is it possible to programmatically enumerate the windows of all current apps
dialog boxes, for example, will open in a new window, independent of the main activity window. I can go through Dialog.getwindow (Find them), but I don't know how I can do this with a built-in component, such as popping up in the active menu.
Is there any way to enumerate all the Windows associated with my application, from the application, context, or window manager, or something else?
I can see the windows of all my applications in the ADB dumpsys window, but I am looking for a way to do this in my application without root.
Android's Android View
Best Answer:
I found a way to windowmanagerglobal through reflection, at least so far he has worked very well in the android-18 version .....
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/[email protected]: com.android.internal.policy.impl.phonewindow$decorview{41dcc278 v.e ..... R....... 0,0-768,1184}
Found root View:popupwindow:42887380/[email protected]: android.widget.popupwindow$popupviewcontainer{42891450 V.E ..... ........ 0,0-424,618}
This address: http://www.itmmd.com/201412/297.html
Android lists all the windows in the current app in a coded way