Android获取获取悬浮窗一下的view办法

getwindows可以获取当前手机屏幕所有有交互功能的view

getactitywindows只能获取最顶层有交互的view

AccessibilityWindowInfo getWindow() Gets the window to which this node belongs.

 

用实例化途径:AccessibilityService.getWindows()获得,返回值是一个list列表。

返回值 方法 描述
AccessibilityNodeInfo getRoot() 获得该窗口的根节点信息
AccessibilityWindowInfo getChild(int index) Gets the child window at a given index.
int getChildCount() Gets the number of child windows.
int getId() Gets the unique window id.
boolean isActive() Gets if this window is active.
boolean isFocused() Gets if this window has input focus.

 

Log.d(
"Window", "--------------------------" )
val windows = acc.windows
// 遍历所有窗口并输出它们的信息
for (window in windows) {
var rect = Rect()
window.getBoundsInScreen(rect)

Log.d(
"Window", "Window ID: " + window.id + ", Type: " + window.type +
", Bounds: " + rect)
}
posted @ 2023-02-03 21:24  it世界库  阅读(226)  评论(0编辑  收藏  举报