热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Androidgraphics:Howanalertwindowisdisplayed?

Androidgraphics:Howanalertwindowisdisplayed?一、initilizationanddatastructure.AlertDialoginh

Android graphics: How an alert window is displayed?

 

一、initilization and data structure.

AlertDialog inherites from Dialog and it hold a member of AlertController mAlert.

 

 

In dialog.java, Dialog in constrcuted. it creates a new phoneWindow, and store it in it's mWindow member.

 the window is registered in WMS. so it can interact with WMS to handle the input from users.

 

 

frameworks/base/policy/src/com/android/internal/policy/impl/Policy.java
frameworks/base/core/java/android/view/Window.java

 

 

164 Window w = PolicyManager.makeNewWindow(mContext);

mWindow = w;
w.setWindowManager(mWindowManager, null, null);
in AlertDiaog constructor, Dialog's phoneWindow will be passed to AlertController's mWindow
alertDialog.java
AlertDialog(Context context, int theme, boolean createThemeContextWrapper) {
mAlert = new AlertController(getContext(), this, getWindow());
}

 

 

二、show() function.

how the dialog window is shown??

you need to invoke the dialog.show() to display the dialog window, before this, you need to 

setup the contents of dialog.

the code snippet is like:

1 AlertDialog.Builder ad = new AlertDialog.Builder(cxt);
2
3 ad.setTitle(title);
4 ad.setMessage(message);
5
6 ad.setPositiveButton(
7 b1string,
8 new DialogInterface.OnClickListener() {
9
10 @Override
11 public void onClick(DialogInterface arg0, int arg1) {
12 // TODO Auto-generated method stub
13
14 }
15 }
16 );
17
18 ad.show();

 

I add a function to print the call stack :

E/SS ( 1973): com.android.internal.policy.impl.PhoneWindow$DecorView.setWindowBackground(PhoneWindow.java:2348)

 

E/SS ( 1973): com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2843)
E/SS ( 1973): com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2884)
E/SS ( 1973): com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
E/SS ( 1973): com.android.internal.app.AlertController.installContent(AlertController.java:262)
E/SS ( 1973): android.app.AlertDialog.onCreate(AlertDialog.java:337)
E/SS ( 1973): android.app.Dialog.dispatchOnCreate(Dialog.java:355)
E/SS ( 1973): android.app.Dialog.show(Dialog.java:260)

 

in the show() , 
1) it first invokes the AlertDialog.onCreate function to installDecor(), which generates the new decorview(), and inflate the view with the contents
2)
the decorView which acts as the root of the view, is registered to the Window manager.

public void show() {

             mWindowManager.addView(mDecor, l);

}
addview里面会生成新的viewroot
frameworks/base/core/java/android/view/WindowManagerGlobal.java

public void addView(View view, ViewGroup.LayoutParams params,

            Display display, Window parentWindow) {

         root = new ViewRootImpl(view.getContext(), display);

}

the role of viewroot is to interact with WMS, so it can receives key input from users, also it can request WMS to do something.

a Viewroot has a new layer, surface , phone window here. After this, it can invoke performTraversal() to ask Choreographer to draw the image.


转:https://www.cnblogs.com/geeks/p/3266051.html



推荐阅读
  • 本文介绍了在Windows环境下使用pydoc工具的方法,并详细解释了如何通过命令行和浏览器查看Python内置函数的文档。此外,还提供了关于raw_input和open函数的具体用法和功能说明。 ... [详细]
  • Android 渐变圆环加载控件实现
    本文介绍了如何在 Android 中创建一个自定义的渐变圆环加载控件,该控件已在多个知名应用中使用。我们将详细探讨其工作原理和实现方法。 ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • 本章将深入探讨移动 UI 设计的核心原则,帮助开发者构建简洁、高效且用户友好的界面。通过学习设计规则和用户体验优化技巧,您将能够创建出既美观又实用的移动应用。 ... [详细]
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • 在使用 MUI 框架进行应用开发时,开发者常常会遇到 mui.init() 和 mui.plusReady() 这两个方法。本文将详细解释它们的区别及其在不同开发环境下的应用。 ... [详细]
  • 在 ExtJS 中,类的别名(alias)是开发过程中非常有用的一个特性。通过别名,开发者可以使用简短且易于记忆的名称来引用复杂的类名。本文将详细探讨如何在 ExtJS API 中使用和定义别名,并提供实例说明。 ... [详细]
  • 基因组浏览器中的Wig格式解析
    本文详细介绍了Wiggle(Wig)格式及其在基因组浏览器中的应用,涵盖variableStep和fixedStep两种主要格式的特点、适用场景及具体使用方法。同时,还提供了关于数据值和自定义参数的补充信息。 ... [详细]
  • Linux设备驱动程序:异步时间操作与调度机制
    本文介绍了Linux内核中的几种异步延迟操作方法,包括内核定时器、tasklet机制和工作队列。这些机制允许在未来的某个时间点执行任务,而无需阻塞当前线程,从而提高系统的响应性和效率。 ... [详细]
  • 本文详细介绍了中央电视台电影频道的节目预告,并通过专业工具分析了其加载方式,确保用户能够获取最准确的电视节目信息。 ... [详细]
  • 使用GDI的一些AIP函数我们可以轻易的绘制出简 ... [详细]
  • 毕业设计:基于机器学习与深度学习的垃圾邮件(短信)分类算法实现
    本文详细介绍了如何使用机器学习和深度学习技术对垃圾邮件和短信进行分类。内容涵盖从数据集介绍、预处理、特征提取到模型训练与评估的完整流程,并提供了具体的代码示例和实验结果。 ... [详细]
  • 在多线程编程环境中,线程之间共享全局变量可能导致数据竞争和不一致性。为了解决这一问题,Linux提供了线程局部存储(TLS),使每个线程可以拥有独立的变量副本,确保线程间的数据隔离与安全。 ... [详细]
  • 实体映射最强工具类:MapStruct真香 ... [详细]
  • 本文探讨了在 Vue 2.0 项目中使用 Axios 获取数据时可能出现的错误,并提供详细的解决方案和最佳实践。 ... [详细]
author-avatar
神秘的绝代双角
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有