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 .....
[Java] view plaincopy650) this.width=650; "src=" Https://code.csdn.net/assets/CODE_ico.png "width=" 12 " Height= "alt=" on code to view the chip "style=" Border:none; "/>650" this.width=650; "src=" Https://code.csdn.net/assets/ico _fork.svg "width=" height= "alt=" derived from My Code slice "style=" border:none; "/>
Private void logrootviews () {
Try {
-
class wmgclass = class.forname ( "Android.view.WindowManagerGlobal"
-
object wmginstnace = wmgclass.getmethod ( "getinstance" null 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