我是靠谱客的博主 虚幻裙子,这篇文章主要介绍framework(一):ActivityThread-笔记,现在分享给大家,希望可以做个参考。

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

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

 

 
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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}
复制代码
1
由main方法进入消息循环。



 

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

最后

以上就是虚幻裙子最近收集整理的关于framework(一):ActivityThread-笔记的全部内容,更多相关framework(一)内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(86)

评论列表共有 0 条评论

立即
投稿
返回
顶部