framework(一):ActivityThread-笔记

ActivityThread 的功能是管理应用程序进程中的主线程,包括调度和执行Activity,broadcasts以及其它的请求操作。

当用户打开一个应用程序时,会由AMS(ActivityMangerService)创建一个ActivityThread,当然ActivityThread并不是一个线程类,但是其所在的线程就是主线程,也就是常说的UI 线程。

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}
由main方法进入消息循环。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值