Android 基本架构
Android分为四个层,从高层到低层分别是应用程序层、应用程序框架层、系统运行库层和Linux核心层。
蓝色的代表java程序,黄色的代码为运行JAVA程序而实现的虚拟机,绿色部分为C/C++语言编写的程序库,红色的代码内核(linux内核+driver)。在Application Framework之下,由C/C++的程序库组成,通过JNI完成从JAVA到C的调用。
Activity和Fragment的生命周期
Activity按Home键退出到后台 onPause()–>onSaveInstanceState()–>onStop() 返回前台 onRestart()–>onStart()–>onResume()
切换横竖屏onPause()–>onSaveInstanceState()–>onStop() –>onCreate()–>onStart()–>onRestoreInstanceState()–>onResume()(注意:设置android:configChanges=”keyboardHidden|orientation|screenSize”或设置android:screenOrientation=”portrait|orientation”固定横竖屏,切屏不会重新调用各个生命周期,只会执行onConfigurationChanged方法)