APP启动优化和Trace分析工具
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
android系统启动流程
- 打开电源 引导芯片代码加载引导程序Boot Loader到RAM中去执行
- BootLoader把操作系统拉起来
- Linux 内核启动开始系统设置,找到一个init.rc文件启动初始化进程
- init进程初始化和启动属性服务,之后开启Zygote进程
- Zygote开始创建JVM并注册JNI方法,开启SystemServer
- 启动Binder线程池和SystemServiceManager,并启动各种服务
- AMS启动Launcher
Launcher(Application)启动
- 当我们点击一个图标时,就到了这个类public final class Launcher extends Activity
执行onClick(View view)方法,会把这个应用的相关信息传入
先获取一个intent—>startActivitySafely(v, intent, tag)–》startActivity(v, intent, tag);–>startActivity(intent); - startActivity(intent)会开一个APP进程
- ActivityThread.java做为入口 用attach开启app 再加载application和activity
thread.attach(false);—》mgr.attachApplication(mAppThread)会通过远端进程去
回调private void handleBindApplication(AppBindData data)
Application app = data.info.makeApplication(创建Application对象
mInstrumentation.callApplicationOnCreate(app);----》 app.onCreate();
黑白屏问题
- 单独做成一个主题
<style name="AppTheme.Launcher">
<item name="android:windowBackground">@drawable/bg</item>
</style>
<style name="AppTheme.Launcher1">
<item name="android:windowBackground">@drawable/bg</item>
</style>
<style name="AppTheme.Launcher2">
<item name="android:windowBackground">@drawable/bg</item>
</style>
- 清单中的单独activity下设置
<activity
android:theme="@style/AppTheme.Launcher"
程序中使用setTheme(R.style.AppTheme);
让APP中所有的activity还是使用以前的样式,只有启动时才使用自己的样式
- QQ中的用法
<item name="android:windowDisablePreview">true</item>
<item name="android:windowBackground">@null</item>
Trace工具分析代码执行时间
开启Trace并设置文件路径
File file = new File(Environment.getExternalStorageDirectory(), "app1.trace");
Debug.startMethodTracing(filePath);
中间为需要统计执行时间的代码
Debug.stopMethodTracing();
trace文件查看
运行启动APP,会在指定路径下生成一个.trace的文件(注意开启存储权限),将此文件拖入AndroidStudio中
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:22 天前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献9条内容
所有评论(0)