WindowManager.addView(View,WindowManager.LayoutParams); 获取addView后的List集合
try {
Class<?> wmGlobalClz = Class.forName("android.view.WindowManagerGlobal");
Method getInstanceMethod = wmGlobalClz.getMethod("getInstance");
Object mGlobal = getInstanceMethod.invoke(null);
Field mViewsField = wmGlobalClz.getDeclaredField("mViews");
mViewsField.setAccessible(true);
ArrayList<View> mViews = (ArrayList<View>) mViewsField.get(mGlobal);
Field mRootsField = wmGlobalClz.getDeclaredField("mRoots");
mRootsField.setAccessible(true);
ArrayList<?> mRoots = (ArrayList<?>) mRootsField.get(mGlobal);
Field mParamsField = wmGlobalClz.getDeclaredField("mParams");
mParamsField.setAccessible(true);
ArrayList<WindowManager.LayoutParams> mParams = (ArrayList<WindowManager.LayoutParams>) mParamsField.get(mGlobal);
@SuppressLint("SoonBlockedPrivateApi")
Field mDyingViewsField = wmGlobalClz.getDeclaredField("mDyingViews");
mDyingViewsField.setAccessible(true);
Object mDyingViews = mParamsField.get(mGlobal);
for(View view : mViews){
Log.d("Test",view.getClass().getName());
}
for(WindowManager.LayoutParams param : mParams){
Log.d("Test",param.toString()+"----"+param.getTitle());
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
|