源码分析:理解Context
Context一般翻译为上下文,它提供了一个应用环境的全局接口,用于访问指定应用的资源和类,以及各种应用级别的操作,如启动Activities与Service、发送广播与注册广播接收器、接收Intents、获取系统服务等等。 Application的Context ActivityThread.java public static void main(String[] args) { // ... ActivityThread thread = new ActivityThread(); thread.attach(false); // ... } private void attach(boolean system) { // ... if (!system) { // ... final IActivityManager mgr = ActivityManager.getService(); try { mgr.attachApplication(mAppThread); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } // ... } // ... } ActivityManagerService.java @Override public final void attachApplication(IApplicationThread thread) { synchronized (this) { int callingPid = Binder.getCallingPid(); final long origId = Binder....