当前位置: 首页 > news >正文

Android ActivityThread

应用程序的入口

当启动应用程序时会由ActivityMangerService孵化一个进程,并且实例化一个ActivityThread对象,该类为fianl类型,并不是一个线程类,该类mian()方法实现了常说的消息循环

 public static void main(String[] args) {
5185
        SamplingProfilerIntegration.start();
5186
 
 
5187
        // CloseGuard defaults to true and can be quite spammy.  We
5188
        // disable it here, but selectively enable it later (via
5189
        // StrictMode) on debug builds, but using DropBox, not logs.
5190
        CloseGuard.setEnabled(false);
5191
 
 
5192
        Environment.initForCurrentUser();
5193
 
 
5194
        // Set the reporter for event logging in libcore
5195
        EventLogger.setReporter(new EventLoggingReporter());
5196
 
 
5197
        Security.addProvider(new AndroidKeyStoreProvider());
5198
 
 
5199
        // Make sure TrustedCertificateStore looks in the right place for CA certificates
5200
        final File configDir = Environment.getUserConfigDirectory(UserHandle.myUserId());
5201
        TrustedCertificateStore.setDefaultUserDirectory(configDir);
5202
 
 
5203
        Process.setArgV0("<pre-initialized>");
5204
 
 
5205
        Looper.prepareMainLooper();
5206
 
 
5207
        ActivityThread thread = new ActivityThread();
5208
        thread.attach(false);
5209
 
 
5210
        if (sMainThreadHandler == null) {
5211
            sMainThreadHandler = thread.getHandler();
5212
        }
5213
 
 
5214
        AsyncTask.init();
5215
 
 
5216
        if (false) {
5217
            Looper.myLooper().setMessageLogging(new
5218
                    LogPrinter(Log.DEBUG"ActivityThread"));
5219
        }
5220
 
 
5221
        Looper.loop();
5222
 
 
5223
        throw new RuntimeException("Main thread loop unexpectedly exited");
5224
    }
5225
}
该类中还有一个内部类ApplicationThread该类可以说是ActivityMangerService和应用程序通信的桥梁,private class ApplicationThread extends ApplicationThreadNative 该类是一个Binder类型结构的,用于通信,可以说是操作应用程序的命令的发送者。

 

转载于:https://www.cnblogs.com/qcjd/p/9324973.html

相关文章:

  • Spring中使用Map、Set、List、数组、属性集合的注入方法配置文件
  • 设计模式-23种参考模式
  • Spring中继承配置的注入方法
  • Spring控制反转和依赖注入
  • springMVC框架搭建流程
  • 四舍五入的方法
  • Java代码生成二维码图片
  • 2.Cocos2dx 3.2重力系统Box2D
  • Ubuntu下安装C/C++开发环境【!!!有更新!!!Ubuntu14.10下使用eclipse搭建C语言开发环境】
  • 翻译一篇文章:It's Difficult to Grow a Test Developer(成为测试开发工程师的艰辛)...
  • Spring的核心机制:依赖注入
  • Spring获取ApplicationContext对象工具类
  • linux基础学习8
  • Ubuntu系统更新命令笔记
  • 大龄屌丝自学笔记--Java零基础到菜鸟--038
  • Android组件 - 收藏集 - 掘金
  • docker容器内的网络抓包
  • EOS是什么
  • flask接收请求并推入栈
  • HashMap剖析之内部结构
  • If…else
  • Laravel 实践之路: 数据库迁移与数据填充
  • vue的全局变量和全局拦截请求器
  • webgl (原生)基础入门指南【一】
  • 聊聊redis的数据结构的应用
  • 人脸识别最新开发经验demo
  • 深度解析利用ES6进行Promise封装总结
  • 使用Maven插件构建SpringBoot项目,生成Docker镜像push到DockerHub上
  • 微信小程序开发问题汇总
  • 学习笔记:对象,原型和继承(1)
  • Linux权限管理(week1_day5)--技术流ken
  • Mac 上flink的安装与启动
  • Redis4.x新特性 -- 萌萌的MEMORY DOCTOR
  • 你学不懂C语言,是因为不懂编写C程序的7个步骤 ...
  • # 飞书APP集成平台-数字化落地
  • ###C语言程序设计-----C语言学习(3)#
  • #《AI中文版》V3 第 1 章 概述
  • #WEB前端(HTML属性)
  • #我与Java虚拟机的故事#连载04:一本让自己没面子的书
  • (145)光线追踪距离场柔和阴影
  • (16)Reactor的测试——响应式Spring的道法术器
  • (TipsTricks)用客户端模板精简JavaScript代码
  • (草履虫都可以看懂的)PyQt子窗口向主窗口传递参数,主窗口接收子窗口信号、参数。
  • (第9篇)大数据的的超级应用——数据挖掘-推荐系统
  • (附源码)springboot家庭财务分析系统 毕业设计641323
  • (论文阅读30/100)Convolutional Pose Machines
  • (删)Java线程同步实现一:synchronzied和wait()/notify()
  • (转) ns2/nam与nam实现相关的文件
  • (转)JAVA中的堆栈
  • (转)创业家杂志:UCWEB天使第一步
  • ***linux下安装xampp,XAMPP目录结构(阿里云安装xampp)
  • .axf 转化 .bin文件 的方法
  • .libPaths()设置包加载目录
  • .NET CORE 第一节 创建基本的 asp.net core
  • .NET DevOps 接入指南 | 1. GitLab 安装