Is it possible to programmatically enumerate all of the android.view.Windows, or decor views within an application?
Dialogs for example wil
Every solution is in Java above and I made the solution for Kotlin converting the Andrew Lavers's answer-
try
{
val wmgClass = Class.forName("android.view.WindowManagerGlobal")
val wagInstance = wmgClass.getMethod("getInstance").invoke(null)
val getViewRootNames: Method = wmgClass.getMethod("getViewRootNames")
val getRootView: Method = wmgClass.getMethod("getRootView", String::class.java)
val rootViewNames = getViewRootNames.invoke(wagInstance) as Array
for (viewName in rootViewNames) {
val rootView = getRootView.invoke(wagInstance, viewName) as View
}
} catch (exception: java.lang.Exception {}