Messaging 源码位于 packages/apps/Messaging 目录下,application类名是BugleApplication,
在 onCreate 方法里做了两件事,
1 FactoryImpl.register(getApplicationContext(), this);
2 Thread.setDefaultUncaughtExceptionHandler(this);
来看看FactoryImpl.register(getApplicationContext(), this);做了什么事情,
public static Factory register(final Context applicationContext, final BugleApplication application) {
// This only gets called once (from BugleApplication.onCreate), but its not called in tests.
Assert.isTrue(!sRegistered);
Assert.isNull(Factory.get());
final FactoryImpl factory = new FactoryImpl();
Factory.setInstance(factory);
sRegistered = true;
// At this point Factory is published. Services can now get initialized and depend on Factory.get().
factory.mApplication = application;
factory.mApplicationContext = applicationContext;
factory.mMemoryCacheManager = new MemoryCacheManager(); // 创建缓缓管理器
factory.mMediaCacheManager = new BugleMediaCacheManager(); // 创建媒体缓存管理器
factory.mMediaResourceManager = new MediaResourceManager(); // 创建媒体资源管理器
factory.mBugleGservices = new