我们知道Activity的生命周期包括onCreate、onStart、onResume、onRestart、onStop、onDestory、onSaveInstanceState、onRestoreInstanceState等等, 那么是谁调用了它呢?
答:是ActivityThread调度的, 具体逻辑封装在Instrumentation类里。 好好看看这2个类就明白了。
Instrumentation类封装了Activity各个生命周期的方法, 所以想办法替换mInstrumentation参数就可以了