Android Application和Application Context区别

在Android9.0、7.0和6.0中Application继承实现关系都是一样的。

Application extends ContextWrapper implements ComponentCallbacks2

Application是继承ContextWrapper 的,我们知道ContextWrapper是Context的包装类,ContextWrapper中有个成员变量mBase其实就是Context。

ComponentCallbacks2中就一个回调方法 onTrimMemory,是用来通知内存应该处理的几种状态。

然后就是:

public interface ActivityLifecycleCallbacks {}
public interface OnProvideAssistDataListener {}
public void onConfigurationChanged(Configuration newConfig)
public void onLowMemory()
public void onTrimMemory(int level)
public void registerComponentCallbacks(ComponentCallbacks callback)
public void registerActivityLifecycleCallbacks(ActivityLifecycleCallbacks callback) 
public void registerOnProvideAssistDataListener(OnProvideAssistDataListener callback)
/* package */ void dispatchActivityCreated(Activity activity, Bundle savedInstanceState) 
/* package */ void dispatchActivityStarted(Activity activity)
/* package */ void dispatchActivityResumed(Activity activity) 
/* package */ void dispatchActivityPaused(Activity activity)
/* package */ void dispatchActivityStopped(Activity activity)
/* package */ void dispatchActivitySaveInstanceState(Activity activity, Bundle outState)
/* package */ void dispatchActivityDestroyed(Activity activity)
private Object[] collectComponentCallbacks()
private Object[] collectActivityLifecycleCallbacks()
/* package */ void dispatchOnProvideAssistData()

你可能感兴趣的:(Android源码分析)