Layout file preloading method and device under Android platform and electronic equipment

文档序号:1215070 发布日期:2020-09-04 浏览:2次 中文

阅读说明:本技术 一种Android平台下布局文件预加载方法、装置及电子设备 (Layout file preloading method and device under Android platform and electronic equipment ) 是由 张清华 于 2020-05-06 设计创作,主要内容包括:本发明属于计算机技术领域,提供一种Android平台下布局文件预加载方法、装置、电子设备和计算机可读介质,通过预先加载的方式加载移动终端资源,提升了应用程序冷启动的速度,方法包括:响应于用户的点击,冷启动应用程序;创建所述应用程序的主进程,所述主进程包括第一线程;根据待解析的资源组件数量在主进程中创建第二线程,所述第二线程解析所述资源组件;所述第一线程加载所述第二线程解析完成的资源组件,完成应用程序冷启动。采用该技术方案,利用移动终端处理器多核的特点,采用异步加载的方式执行应用程序的冷启动,在启动过程中提前加载资源组件,从而达到应用程序加载速度以及启动速度加快的目的。(The invention belongs to the technical field of computers, and provides a layout file preloading method, a layout file preloading device, electronic equipment and a computer readable medium under an Android platform, wherein mobile terminal resources are loaded in a preloading mode, so that the cold start speed of an application program is increased, and the method comprises the following steps: responding to the click of the user, and cold starting the application program; creating a main process of the application program, wherein the main process comprises a first thread; creating a second thread in the main process according to the number of resource assemblies to be analyzed, wherein the second thread analyzes the resource assemblies; and the first thread loads the resource assembly analyzed and completed by the second thread to complete the cold start of the application program. By adopting the technical scheme, the cold start of the application program is executed in an asynchronous loading mode by utilizing the characteristic of multi-core of the mobile terminal processor, and the resource component is loaded in advance in the starting process, so that the aims of accelerating the loading speed and the starting speed of the application program are fulfilled.)

1. A layout file preloading method under an Android platform is characterized by comprising the following steps:

responding to the click of the user, and cold starting the application program;

creating a main process of the application program, wherein the main process comprises a first thread;

creating a second thread in the main process according to the number of resource assemblies to be analyzed, wherein the second thread analyzes the resource assemblies;

and the first thread loads the resource assembly analyzed and completed by the second thread to complete the cold start of the application program.

2. The method for preloading a layout file according to claim 1, wherein the creating a host process of the application program, the host process including a first thread, further comprises:

the first thread creates and initializes Application;

the first thread calls the onCreate function to create and initialize MainActivity.

3. The method for preloading a layout file according to any one of claims 1 to 2, wherein the creating of the second threads in the main process according to the number of resource components to be resolved is specifically to create the same number of second threads according to the number of resource components;

optionally, the second thread parsing the resource component further comprises,

setting the PRIORITY of the second THREAD as a visible THREAD read _ PRIORITY _ DISPLAY;

setting a class loader ClassLoader of the second thread, which is used for loading a corresponding loading class in the resource component;

creating the resource assembly analyzer, analyzing the resource assembly and obtaining the corresponding View;

and putting the corresponding View obtained by analyzing the resource component into a memory.

4. The method of any of claims 1 to 3, wherein the loading of the resource component parsed by the second thread by the first thread further comprises the onCreat function reading the View from memory;

optionally, the onCreat function reading the View from memory further comprises,

the onCreat function calls a setContentView function to construct a DecorView;

and reading the second thread View from the memory, and adding the View to the DecorView.

5. The layout file preloading method of any one of claims 1 to 4, wherein the completing the application cold start further comprises:

and adding the DecorView added with the View into the Window to finish the cold start of the application program.

6. The layout file preloading device under the Android platform is characterized by comprising:

the response module is used for responding to the click of the user and cold starting the application program;

the first thread creating module is used for creating a main process of the application program, and the main process comprises a first thread;

the second thread creating module is used for creating a second thread in the main process according to the number of the resource assemblies to be analyzed, and the second thread analyzes the resource assemblies;

and the first thread loads the resource assembly analyzed and completed by the second thread to complete the cold start of the application program.

7. The layout file preloading device according to claim 6, wherein creating a main process of the Application program, the main process including a first thread further comprises the first thread creating and initializing Application;

the first thread calls the onCreate function to create and initialize MainActivity.

8. The layout file preloading device according to any one of claims 6 or 7, wherein the creating of the second threads according to the number of resource components to be resolved is specifically to create the same number of second threads according to the number of resource components;

optionally, the second thread parsing the resource component further comprises,

setting the PRIORITY of the second THREAD as a visible THREAD read _ PRIORITY _ DISPLAY;

setting a class loader ClassLoader of the second thread, which is used for loading a corresponding loading class in the resource component;

creating the resource assembly analyzer, analyzing the resource assembly and obtaining the corresponding View;

putting the corresponding View obtained by analyzing the resource component into a memory;

optionally, the loading, by the first thread, the resource component that is resolved by the second thread further includes reading, by the onCreat function, the View from a memory.

9. An electronic device comprising a processor and a memory, the memory for storing a computer-executable program, characterized in that:

the computer program, when executed by the processor, performs the method of any of claims 1-7.

10. A computer-readable medium storing a computer-executable program, wherein the computer-executable program, when executed, implements the method of any of claims 1-7.

17页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:数据处理模型自动迭代方法、装置及电子设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!