在博客《WindowManager杂谈》和《关于PopupWindow的简单说明》这两篇博客中简单的说明了一下WindowManger的创建过程以及WindowManager在PopupWindow的是如何使用的。详细看参考上述的两篇博客。我们知道,在实际开发中可以通过如下一行代码获取WindowManager对象:
(WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)
很简单,通过Context对象的getSystemServcie方法来获取的,关于该方法的详细实现原理读过《getSystemService的简单说明 》就可以知道WindowManager是在如下的代码里面得到了注册和初始化:
registerService(WINDOW_SERVICE, new ServiceFetcher() {
public Object getService(ContextImpl ctx) {
return WindowManagerImpl.getDefault(ctx.mPackageInfo.mCompatibilityInfo);
}});
通过上面的这段代码