标签:
一.启动Activity需要两个Binder线程(Binder_1;Binder_2)的支持。启动Service同样需要。 他俩的主线程都是ActivityThread。 Looper.loop()是在ActivityThread的main(string[] args)中被调用的
public static void main(String[] args) {
SamplingProfilerIntegration.start();
CloseGuard.setEnabled(false);
Environment.initForCurrentUser();
EventLogger.setReporter(new EventLoggingReporter());
Security.addProvider(new AndroidKeyStoreProvider());
final File configDir = Environment.getUserConfigDirectory(UserHandle.myUserId());
TrustedCertificateStore.setDefaultUserDirectory(configDir);
Process.setArgV0("<pre-initialized>");
Looper.prepareMainLooper();
ActivityThread thread = new ActivityThread();
thread.attach(false);
if (sMainThreadHandler == null) {
sMainThreadHandler = thread.getHandler();
}
AsyncTask.init();
if (false) {
Looper.myLooper().setMessageLogging(new
LogPrinter(Log.DEBUG, "ActivityThread"));
}
Looper.loop();
throw new RuntimeException("Main thread loop unexpectedly exited");
}
二.对于同一个AndroidManifest.xml中定义的四大组件,除非有特别声明(回来补充),否则它们都运行于同一个进程中(并且均由主线程来处理事件)
标签:
原文地址:http://www.cnblogs.com/ztSpace/p/4742665.html