首先我們來看下源碼中源於Activity的定義:
- public class Activity extends ContextThemeWrapper
- implements LayoutInflater.Factory2,
- Window.Callback, KeyEvent.Callback,
- OnCreateContextMenuListener, ComponentCallbacks2 {
- ...
- }
下面我們來詳細分析每一部分的具體意義:
extends ContextThemeWrapper表示Activity本質上是一個ContextThemeWrapper,而ContextThemeWrapper具體是什麼呢?看ContextThemeWrapper在源碼中的定義:
- public class ContextThemeWrapper extends ContextWrapper {
- ...
- }
可見ContextThemeWrapper是一個ContextWrapper,繼續往下看:
- public class ContextWrapper extends Context {
- Context mBase;
- ...
- }
ContextWrapper本質上是一個Context,context 的定義如下:
- public abstract class Context {
- ...
- }
整體結構如下圖所示