Application program running method and device, electronic equipment and storage medium

By judging the system type in the car computer system application and loading customized classes or stand-alone classes, the compatibility problem of car computer system application in different Framework environments is solved, ensuring that the application runs normally in different systems, and improving the user experience.

CN120255975APending Publication Date: 2025-07-04GREAT WALL MOTOR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510289768.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-12
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

The existing car system applications have compatibility problems in different Framework environments, causing the application to report errors and crashes, affecting the user experience.

Method used

By determining the system type when the application starts and loading the corresponding customized class or stand-in class, ensure that the application can run normally in both customized systems and non-custom systems. The stand-alone class has the same class structure as the customized class. The stand-alone class provides similar functions in non-customized systems to reduce dependence on specific system environments.

Benefits of technology

Improves application compatibility, reduces error reporting and crashes, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120255975A_ABST
    Figure CN120255975A_ABST
Patent Text Reader

Abstract

The invention provides a running method and device of an application program, electronic equipment and a storage medium, the method is applied to the field of computers, and the method comprises the following steps: under the condition that a starting instruction for the application program is received, judging whether a current running system of the application program is a customized system or not; if the current running system of the application program is a customization system, loading a customization class in the customization system so as to execute a customization function corresponding to the customization class in the running process of the application program; and if the current running system of the application program is a non-customized system, loading a substitute class in the non-customized system so as to assist the application program to run in the non-customized system. According to the method, the corresponding class can be loaded according to the system type, it is ensured that the application program can normally run in different system environments, the compatibility of the application program is improved, and the use experience of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and more particularly, to a method, apparatus, electronic device, and storage medium for running an application program in the field of computers. Background Art

[0002] Existing in-vehicle infotainment (IVI) systems are usually deeply customized based on the Android system. In order to provide users with more powerful and personalized functions, IVI application developers will integrate a jar package containing customized application programming interfaces (APIs) provided by the system Framework into the IVI applications.

[0003] With the continuous changes in the software and hardware of the IVI system, the application programs in the IVI need to adapt to multiple underlying hardware platforms and Framework environments. If the customized interface does not exist in the Framework environment where the application program runs, problems such as application error reporting and crashing will occur, resulting in a poor user experience. Summary of the Invention

[0004] This application provides a method, apparatus, electronic device, and storage medium for running an application program. The method can load corresponding classes according to the system type, ensuring that the application program can run normally in different system environments, improving the compatibility of the application program, and enhancing the user experience.

[0005] In a first aspect, a method for running an application program is provided. The method includes: when receiving an opening instruction for the application program, determining whether the system on which the application program is currently running is a customized system; if the system on which the application program is currently running is a customized system, loading the customized classes in the customized system to execute the customized functions corresponding to the customized classes during the running of the application program; if the system on which the application program is currently running is a non-customized system, loading the substitute classes in the non-customized system to assist the application program in running in the non-customized system; wherein, the substitute classes and the customized classes have the same class structure.

[0006] In the above technical solution, by determining the type of the currently running system when the application starts and loading corresponding classes according to the system type, it can ensure that the application can run normally in different system environments. During the running process of the application, when a customized function is called in a non-customized system, since the proxy class has the same class structure as the customized class, the proxy class can be called in the non-customized system in the same way as the customized class is called in the customized system, enabling the basic interaction logic of the application in the non-customized system to continue, which helps to maintain the normal running of the application. And by dynamically loading different classes to adapt to different system environments, the dependence of the application on a specific system environment is reduced, the compatibility of the application is improved, the occurrence of problems such as application error reporting and crashing is reduced, and the user experience is enhanced.

[0007] Combined with the first aspect, in some implementation manners of the first aspect, before determining whether the system on which the application is currently running is a customized system, the method further includes: creating a proxy class with the same class structure as the customized class in the code corresponding to the application, and adding an identification method in the proxy class that differentiates from the customized class.

[0008] In the above technical solution, by creating a proxy class with the same class structure as the customized class in the code corresponding to the application, it can ensure that the application can run normally in different system environments (customized system and non-customized system). In a non-customized system, since there is no special environment on which the customized class depends, the proxy class can replace the customized class to provide similar functions, ensuring that the basic functions of the application are not affected, thereby enhancing the compatibility of the application in different systems and enabling the application to adapt to a wider range of running environments. Adding an identification method in the proxy class that differentiates from the customized class can provide a clear basis for determining the type of the system on which the application is currently running, facilitating more accurate inference of the corresponding system type of the currently running system subsequently, and providing a basis for selecting appropriate running logic according to the system type subsequently.

[0009] Combined with the first aspect and the above implementation manner, in some implementation manners of the first aspect, determining whether the system on which the application is currently running is a customized system includes: determining whether the class called during the running of the application is a proxy class; if the class called during the running of the application is a proxy class, it is determined that the system on which the application is currently running is a non-customized system; if the class called during the running of the application is not a proxy class, it is determined that the system on which the application is currently running is a customized system.

[0010] Combined with the first aspect and the above implementation manners, in some implementation manners of the first aspect, determining whether the class called during the running of the application is a substitute class includes: determining whether the class called during the running of the application contains an identification method; wherein, the identification method is a method that differentiates the substitute class from the customized class; if there is an identification method, determining that the class called during the running of the application is a substitute class; if there is no identification method, determining that the class called during the running of the application is not a substitute class.

[0011] In the above technical solution, by determining whether the class called during the running of the application contains an identification method, it is determined whether a substitute class or a customized class is used, and then the system type in which the application runs is determined according to the class called during the running of the application, which is convenient for the application to flexibly switch the running logic in different systems. For example, a substitute class is used in a non-customized system to ensure the implementation of the basic functions of the application, enabling the application to run normally in a wider system environment and enhancing the compatibility of the application.

[0012] Combined with the first aspect and the above implementation manners, in some implementation manners of the first aspect, before determining whether the system in which the application is currently running is a customized system, the method further includes: determining whether the running of the application requires calling a customized class; in the case of determining that a customized class needs to be called, performing the determination of whether the system in which the application is currently running is a customized system.

[0013] Combined with the first aspect and the above implementation manners, in some implementation manners of the first aspect, determining whether the running of the application requires calling a customized class includes: obtaining the function requirements corresponding to the application; determining whether the function requirements depend on the customized functions provided by the customized class; if the function requirements depend on the customized functions provided by the customized class, determining that the running of the application requires calling the customized class; if the function requirements do not depend on the customized functions provided by the customized class, determining that the running of the application does not require calling the customized class.

[0014] In the above technical solution, by obtaining the function requirements of the application and determining whether it depends on the customized class, it is possible to accurately determine whether a customized class needs to be called. If the function requirements do not depend on the customized functions provided by the customized class, there is no need to call the customized class, which can avoid wasting system resources on loading the customized class when there is no need to rely on the customized functions provided by the customized class. And since the customized class is only loaded and used in the customized system, so in the case of determining that a customized class needs to be called, then determining whether the system in which the application is currently running is a customized system can make the system resources be reasonably allocated according to the actual needs and improve the utilization rate of the resources.

[0015] Combined with the first aspect and the above implementation manners, in some implementation manners of the first aspect, loading a substitute class in the non-customized system to assist the application program to run in the non-customized system includes: loading the substitute class in the non-customized system to enable the substitute class to assist the application program to run in the non-customized system according to the compatibility logic; wherein, the compatibility logic refers to the rules followed by the application program when running in the non-customized system.

[0016] In the above technical solution, when the application program runs in the non-customized system, loading the substitute class enables the application program to still run smoothly in the absence of the special system environment relied on by the customized class. The substitute class provides functions similar to or substitutable for the customized class according to the compatibility logic, ensuring that the core functions of the application program are not affected by system differences. The substitute class performs operations according to the compatibility logic, which can ensure the normal operation of the application program, reduce the occurrence of errors and exceptions caused by system environment differences, and improve the stability and reliability of the application program.

[0017] In a second aspect, there is provided a running device for an application program. The device includes: a judgment module, configured to judge whether the system on which the application program is currently running is a customized system when receiving an opening instruction for the application program; a first loading module, configured to load a customized class in the customized system to execute the customized function corresponding to the customized class during the running process of the application program if the system on which the application program is currently running is a customized system; a second loading module, configured to load a substitute class in the non-customized system to assist the application program to run in the non-customized system if the system on which the application program is currently running is a non-customized system; wherein, the substitute class and the customized class have the same class structure.

[0018] Combined with the second aspect, in some implementation manners of the second aspect, the device further includes a creation module, and the creation module is specifically configured to: create a substitute class having the same class structure as the customized class in the code corresponding to the application program, and add an identification method that differentiates from the customized class in the substitute class.

[0019] Combined with the second aspect and the above implementation manners, in some implementation manners of the second aspect, the judgment module is specifically configured to: judge whether the class called by the application program during running is a substitute class; if the class called by the application program during running is a substitute class, determine that the system on which the application program is currently running is a non-customized system; if the class called by the application program during running is not a substitute class, determine that the system on which the application program is currently running is a customized system.

[0020] Combined with the second aspect and the above implementation manners, in some implementation manners of the second aspect, the determination module includes a substitute class determination unit, and the substitute class determination unit is specifically configured to: determine whether the class called by the application program during operation contains an identification method; wherein, the identification method is a method that differentiates the substitute class from the customized class; if there is an identification method, determine that the class called by the application program during operation is a substitute class; if there is no identification method, determine that the class called by the application program during operation is not a substitute class.

[0021] Combined with the second aspect and the above implementation manners, in some implementation manners of the second aspect, the apparatus further includes a second determination module, and the second determination module is specifically configured to: determine whether the operation of the application program needs to call the customized class; in the case of determining that the customized class needs to be called, determine whether the system on which the application program is currently running is a customized system.

[0022] Combined with the second aspect and the above implementation manners, in some implementation manners of the second aspect, the second determination module includes a requirement determination unit, and the requirement determination unit is specifically configured to: obtain the functional requirements corresponding to the application program; determine whether the functional requirements depend on the customized functions provided by the customized class; if the functional requirements depend on the customized functions provided by the customized class, determine that the operation of the application program needs to call the customized class; if the functional requirements do not depend on the customized functions provided by the customized class, determine that the operation of the application program does not need to call the customized class.

[0023] Combined with the second aspect and the above implementation manners, in some implementation manners of the second aspect, the second loading module is specifically configured to: load the substitute class in the non-customized system, so that the substitute class assists the application program to run in the non-customized system according to the compatibility logic; wherein, the compatibility logic refers to the rules followed by the application program when running in the non-customized system.

[0024] In a third aspect, an electronic device is provided, including a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, so that the electronic device executes the operation method of the application program in the first aspect and any possible implementation of the first aspect.

[0025] In a fourth aspect, a computer program product is provided, and the computer program product includes: computer program code, when the computer program code runs on a computer, the computer is enabled to execute the operation method of the application program in the first aspect and any possible implementation of the first aspect.

[0026] Fifth aspect, there is provided a computer-readable storage medium storing computer program code which, when run on a computer, causes the computer to execute the method for running an application program in the first aspect and any possible implementation of the first aspect. Description of the Drawings

[0027] Figure 1 is a schematic flowchart of a method for running an application program provided by an embodiment of the present application;

[0028] Figure 2 is a schematic flowchart of a class loading mechanism provided by an embodiment of the present application;

[0029] Figure 3 is a schematic structural diagram of an apparatus for running an application program provided by an embodiment of the present application;

[0030] Figure 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed Embodiments

[0031] Hereinafter, the technical solutions in the present application will be clearly and elaborately described in conjunction with the accompanying drawings. Among them, in the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B may represent A or B. The "and / or" in the text is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality of" means two or more than two.

[0032] Hereinafter, the terms "first" and "second" are only for descriptive purposes and cannot be construed as implying or suggesting relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features.

[0033] Existing in-vehicle systems usually perform in-depth customization based on the Android system. In order to provide users with more powerful and personalized functions, in-vehicle application developers will integrate a jar package containing customized APIs provided by the system Framework into the in-vehicle applications.

[0034] With the continuous changes in the software and hardware of the in-vehicle system, the application programs in the in-vehicle need to adapt to multiple underlying hardware platforms and Framework environments. If there is no customized interface in the Framework environment where the application program runs, problems such as application errors and crashes will occur, resulting in a poor user experience.

[0035] Exemplarily, if a certain application was initially designed for the in-vehicle system of a specific vehicle model, and the system provides specific interfaces for implementing voice control and navigation functions. When this application is deployed to another vehicle model, it is found that these specific interfaces do not exist in the Framework environment of this vehicle model. And if this application is run in the in-vehicle system of another vehicle model, these specific interfaces will be directly called. Since the interfaces do not exist, it may cause the application to report an error or crash, seriously affecting the user experience.

[0036] To solve the above technical problems, an embodiment of the present application provides a method for running an application. The execution subject of this method is an electronic device, which can run the application. For example, the electronic device can be a mobile phone, a computer, a smart TV, an in-vehicle computer in a vehicle, etc. The following takes the method for running an application applied to an in-vehicle computer in a vehicle as an example for illustration:

[0037] Figure 1 It is a schematic flowchart of a method for running an application provided by an embodiment of the present application.

[0038] Exemplarily, as Figure 1 shown, the method 100 includes:

[0039] S101, when receiving an opening instruction for the application, determine whether the system on which the application is currently running is a customized system.

[0040] S102, if the system on which the application is currently running is a customized system, load the customized class in the customized system to execute the customized function corresponding to the customized class during the running process of the application.

[0041] S103, if the system on which the application is currently running is a non-customized system, load the substitute class in the non-customized system to assist the application in running in the non-customized system.

[0042] Among them, the substitute class has the same class structure as the customized class.

[0043] In the embodiments of the present application, by determining the type of the currently running system when the application is started and loading corresponding classes according to the system type, it can be ensured that the application can run normally in different system environments. During the running of the application, when a customized function is called in a non-customized system, since the class structures of the substitute class and the customized class are the same, the substitute class can be called in the non-customized system just like the customized class is called in the customized system, so that the basic interaction logic of the application in the non-customized system can be continued, which helps to maintain the normal running of the application. And by dynamically loading different classes to adapt to different system environments, the dependence of the application on a specific system environment is reduced, the compatibility of the application is improved, the occurrence of problems such as application error reporting and crashing is reduced, and the user experience is enhanced.

[0044] The following specifically describes the implementation manners of each step in the Figure 1 illustrated embodiment:

[0045] Regarding the above S101, it can be understood that the above opening instruction for the application refers to the command to start or activate the application. For example, the opening instruction can be initiated by the user clicking on an icon or by other interaction methods of the user.

[0046] The functions and interfaces provided by different types of systems are different. A customized system may have specific customized functions and interfaces. If an application runs on a customized system, usually customized classes adapted to the customized system need to be loaded to complete the expected tasks of the application in the customized environment, that is, to execute the corresponding customized functions.

[0047] Based on this, when receiving the opening instruction for the application, it can first be determined whether the system on which the application is currently running is a customized system, and then according to the judgment result, different classes are loaded to ensure the normal running of the application.

[0048] In a possible situation, for some applications, the functions they provide may need to be implemented by using the customized interfaces or customized classes of a specific system (such as a customized system), that is, the customized classes need to be called to ensure the running. While the functions of some other applications are relatively general and do not need to rely on the special functions of the customized system, that is, there is no need to call the customized classes to ensure the running.

[0049] Based on this, it can first be determined whether the running of the application requires calling customized classes. When it is determined that the running of the application requires calling customized classes, it is then determined whether the system on which the application is currently running is a customized system.

[0050] In a possible implementation, before determining whether the system on which the application is currently running is a customized system, the method further includes: determining whether the operation of the application requires calling a customized class; and if it is determined that a customized class needs to be called, determining whether the system on which the application is currently running is a customized system.

[0051] It can be understood that the above-mentioned customized class is usually written to use the customized resources of the customized system and execute customized functions, and the customized class usually contains specific logic and code for interacting with the customized system.

[0052] Furthermore, the functions of the application are diverse. The implementation of some functions of the application may depend on the special functions or specific interfaces provided by the customized system, while the implementation of some other functions may not depend on the special functions or specific interfaces provided by the customized system. Based on this, it can be determined whether the operation of the application requires calling a customized class by determining whether the functional requirements of the application depend on the customized functions provided by the customized class.

[0053] In a possible implementation, determining whether the operation of the application requires calling a customized class includes: obtaining the functional requirements corresponding to the application; determining whether the functional requirements depend on the customized functions provided by the customized class; if the functional requirements depend on the customized functions provided by the customized class, determining that the operation of the application requires calling the customized class; and if the functional requirements do not depend on the customized functions provided by the customized class, determining that the operation of the application does not require calling the customized class.

[0054] It can be understood that by obtaining the functional requirements corresponding to the application, it is possible to clarify which specific functions the application needs to implement.

[0055] Exemplarily, the specific functional requirements corresponding to the application can be determined according to the interaction instructions of the user in the interface of the application (such as clicking a button, selecting a menu option, entering text, etc.).

[0056] For example, in an image editing application, when the user clicks the "Crop" button, this indicates that the user has a functional requirement for cropping the image, and the application needs to have the corresponding image cropping function to respond to the user's operation.

[0057] Furthermore, by obtaining the functional requirements corresponding to the application, it can be determined whether the implementation of these functions depends on the customized functions provided by the customized class.

[0058] As mentioned above, the customized class is usually designed for a specific customized system and can be used to implement some special functions in the application, that is, customized functions.

[0059] Exemplarily, if a certain application needs to implement an interaction function with a specific hardware device, and the driver and operation of this hardware device both need to be completed using a custom class, then the implementation of this function depends on the custom class, and it is determined that the operation of this application requires calling the custom class.

[0060] Through the above method, by obtaining the functional requirements of the application and determining whether it depends on the custom class, it is possible to accurately determine whether to call the custom class. If the functional requirements do not depend on the custom class, there is no need to call the custom class, which can avoid wasting system resources on loading the custom class when the custom class function is not required. And since the custom class is only loaded and used in the custom system, when it is determined that the custom class needs to be called, then judging whether the system on which the application is currently running is a custom system can reasonably allocate system resources according to actual needs and improve the utilization rate of resources.

[0061] Normally, after the application starts, when the application class loader receives a request to load a class, it will first delegate the request upward to the superior class loader. Only when the superior class loader fails to load the class will the application class loader attempt to load it itself.

[0062] It can be understood that class loading refers to the process of loading the bytecode file of a class (in the form of a.class file, etc.) into memory so that it can be used by the application.

[0063] Exemplarily, as Figure 2 shown, there are three types of class loaders in the figure, including the bootstrap class loader, the extension class loader, and the application class loader.

[0064] Among them, the bootstrap class loader is the topmost class loader, the extension class loader is a subclass of the bootstrap class loader, and the application class loader is a subclass of the extension class loader.

[0065] It can be understood that: the bootstrap class loader is the superior class loader of the extension class loader, and the extension class loader is the superior class loader of the application class loader.

[0066] Specifically, when the application class loader receives a task to load a class, it will not directly load it, but first delegate the loading request to the extension class loader. The extension class loader will also not directly load it and then delegate the request to the bootstrap class loader. This process is to delegate upward along the hierarchy of class loaders (i.e., "upward search to check if it has been loaded" in the figure), aiming to check whether the class to be loaded has already been loaded by the superior class loader. If the superior class loader can find and load the class, it will directly return an instance of the class without subsequent loading operations.

[0067] Similarly, during the class loading process, if the bootstrap class loader cannot find the corresponding class, it will return the request to the extension class loader to attempt to load it. If the extension class loader also cannot find it, it will be returned to the application class loader for an attempt to load (i.e., "attempt to load the class downward" in the figure). Only when all the upper-level class loaders are unable to load, will the current class loader itself attempt to load the class from the specified path.

[0068] To ensure that classes can be successfully loaded during the runtime of the application and that the application can run smoothly in different systems with or without a customized interface (i.e., customized class), a substitute class with the same parameters as the customized class can be created in advance in the source code of the application.

[0069] Among them, this substitute class can replace the customized class in a system without a customized interface to implement similar functions. Even when the application runs in a system without a customized interface, the normal operation of the application can be ensured through the substitute class.

[0070] In one possible implementation, before determining whether the system where the application is currently running is a customized system, this method further includes: creating a substitute class with the same class structure as the customized class in the code corresponding to the application, and adding an identification method in the substitute class that differentiates it from the customized class.

[0071] It can be understood that creating a substitute class with the same class structure as the customized class in the code corresponding to the application specifically means creating a substitute class with the same path, the same method name, and the same method parameters in the source code of the application.

[0072] Specifically, in the source code of the application, classes are usually organized according to a certain package structure (i.e., path). When creating the substitute class, ensuring that the substitute class has the same path as the customized class can ensure the consistency of the class's position in the code.

[0073] The method name is the identifier of the function in the class. When creating the substitute class, ensuring that the substitute class has the same method name as the customized class can ensure that they have a certain corresponding relationship in terms of function. When the application is running, after selecting to load the customized class or the substitute class according to the system environment, due to the same method name, the code corresponding to these methods does not need to be modified when the application calls these methods during the running process, improving the portability and compatibility of the code.

[0074] The method parameters determine the input and call method of the method. When creating the substitute class, ensuring that the substitute class has the same method parameters as the customized class can ensure that during the running process of the application, when switching between the customized class and the substitute class according to different system environments, the code calling these methods does not need to be modified, improving the portability of the code.

[0075] Exemplarily, if there is a customized API in the in-vehicle system of vehicle A, the specific full class path of this customized API is: com.demo.system.api.ViewKit, and there is a method inside this class: getViewDominantColor(View view), whose function is to obtain the dominant color of the corresponding view View. This means that in the native operating environment of the in-vehicle system of vehicle A, if an application wants to obtain the dominant color of a view, it can call this customized API to achieve it.

[0076] To improve the compatibility of the application, when writing the application code, a ViewKit class with the same path as the customized API (com.demo.system.api) can be created under the source code directory of the application. At the same time, a method with the same name getViewDominantColor(View view) is created under the source code directory of the application to obtain a substitute class that replaces the function of the original customized API, so that in different system environments, the application can call this method in the same way to try to obtain the dominant color of the view.

[0077] In some embodiments, in order to meet the compatibility requirements as needed inside the getViewDominantColor(View view) method, the following processing can be carried out according to the actual situation:

[0078] (1) The implementation code of the original getViewDominantColor(View view) method in the Framework can be referred to to write code that can achieve the same function. By imitating the original implementation logic, the consistency and accuracy of the function are ensured.

[0079] (2) If the function of the customized API cannot be fully implemented in some system environments, or the implementation cost is too high, the default value can be selected and no specific implementation is done. For example, if the function of obtaining the dominant color of the view cannot be fully implemented in some system environments, a preset color value can be returned as the default dominant color, so that the application can continue to run. Although the function may not be as powerful as the native customized API, it can still meet the basic usage requirements.

[0080] (3) When the function of the customized API is not supported at all in a specific system environment, the function can be blocked, that is, an exception is thrown. By throwing an exception, the upper-layer business code can catch this exception and actively hide the functions related to the customized API according to the exception situation to avoid errors or incompatibilities.

[0081] In some embodiments, in addition to creating a proxy class in the source code of the application, a unified compatibility library can also be used to implement the functions of the proxy class.

[0082] Among them, the compatibility library is a code library developed and maintained uniformly by a third party or the development team. The compatibility library contains implementations of various proxy classes. These proxy classes are designed for common customized class functions and multiple non-customized system environments, and have generality and reusability.

[0083] During the development of the application, this compatibility library can be integrated into the application. When the application runs on a non-customized system, the proxy classes provided in the compatibility library can be directly used to implement the functions provided by the customized class, ensuring the normal operation of the application.

[0084] Due to the latency of class loading, after the class loading process is completed, it may not be possible to know which class the application is actually using during runtime, and thus it is impossible to determine whether the system on which the application is currently running is a customized system or a non-customized system. This may lead to compatibility errors during the operation of the application, affecting the subsequent operation of the application.

[0085] To better distinguish between the proxy class and the customized class, an identification method that differentiates from the customized class can be added to the proxy class.

[0086] Exemplarily, a new method isCustomKit() can be created in the self-written ViewKit class (i.e., the proxy class), and the role of this method is to differentiate from the customized class.

[0087] The above method can ensure the normal operation of the application in different system environments (customized systems and non-customized systems) by creating a proxy class with the same class structure as the customized class in the corresponding code of the application. In a non-customized system, since there is no special environment on which the customized class depends, the proxy class can replace the customized class to provide similar functions, ensuring that the basic functions of the application are not affected, thereby enhancing the compatibility of the application in different systems and enabling the application to adapt to a wider range of operating environments. Adding an identification method that differentiates from the customized class in the proxy class can provide a clear basis for determining the system type on which the application is currently running, facilitating more accurate inference of the corresponding system type of the currently running system subsequently, and providing a basis for selecting the appropriate running logic according to the system type subsequently.

[0088] It can be understood that the above-added identification method in the proxy class can specifically be used to identify whether the class called during the operation of the application is a proxy class.

[0089] In some embodiments, to determine the type of the system on which the application is currently running, the basic part of the class can be initially loaded. Based on the basic part of the class loaded initially, it is determined whether the system on which the application is currently running is a customized system. After determining the type of the system on which the application is currently running, the complete class corresponding to the system type is then loaded.

[0090] Among them, the basic part of the above class can include basic information related to indicating the system type, such as an identification method for identifying a proxy class. The above complete class can include the complete functions and running logic required to complete specific tasks.

[0091] In a possible implementation, determining whether the system on which the application is currently running is a customized system includes: determining whether the class called by the application during operation is a proxy class; if the class called by the application during operation is a proxy class, it is determined that the system on which the application is currently running is a non-customized system; if the class called by the application during operation is not a proxy class, it is determined that the system on which the application is currently running is a customized system.

[0092] It can be understood that, as described above, when creating a proxy class, an identification method that differentiates from the customized class is added to the proxy class. Based on this, it can be determined whether the class called by the application is a proxy class by determining whether the identification method is included in the class called by the application.

[0093] In a possible implementation, determining whether the class called by the application during operation is a proxy class includes: determining whether the class called by the application during operation includes an identification method; where the identification method is a method in the proxy class that differentiates from the customized class; if there is an identification method, it is determined that the class called by the application during operation is a proxy class; if there is no identification method, it is determined that the class called by the application during operation is not a proxy class.

[0094] It can be understood that generally, the reflection mechanism can be used to determine whether the identification method is included in the class called by the application.

[0095] Exemplarily, when the application starts, a running environment such as the Java Virtual Machine (JVM) initially loads (i.e., calls) classes according to the needs of the application.

[0096] Among them, class loading refers to the process of loading the bytecode file (.class file) of the class into memory and creating a corresponding Class object.

[0097] Although the classes are initially loaded when the above application starts (i.e., the classes have been called), the application cannot know specifically what classes are initially loaded into memory, nor can it know whether the currently running system is a customized system or a non-customized system. Therefore, it cannot execute different running logics according to different systems to ensure the normal operation of the application. Based on this, the information in the initially loaded classes can be obtained through the reflection mechanism, so as to determine specifically what classes are initially loaded.

[0098] The above reflection mechanism refers to the ability to obtain, inspect, and modify its own state or behavior when a computer program is running, and it depends on the Class object to achieve.

[0099] Specifically, the reflection mechanism can be used to access various information of a class through the Class object, including determining whether there is a specific method (i.e., the recognition method described above) in the classes initially loaded by the application.

[0100] Furthermore, the classes initially loaded by the application (i.e., the called classes) may be part of the customized classes or part of the substitute classes. Due to the different designs of the customized classes and the substitute classes, there may be two situations in the reflection results: the recognition method exists and the recognition method does not exist.

[0101] It can be understood that if the reflection result indicates the existence of the recognition method, it is determined that the classes initially loaded by the application (i.e., the called classes) are substitute classes; if the reflection result indicates the non-existence of the recognition method, it is determined that the classes initially loaded by the application (i.e., the called classes) are customized classes.

[0102] Furthermore, since the substitute classes are designed for non-customized systems, they do not depend on the special functions of the customized systems. When the application is running, if the initially loaded classes are substitute classes, it means that the current system environment cannot support the operation of the customized classes, that is, it does not have the special conditions of the customized system. Therefore, it can be determined that the currently running system is a non-customized system.

[0103] On the contrary, if the classes initially loaded by the application are not substitute classes, it is possible that the classes called by the application during operation are customized classes, and the customized classes can only run normally in the customized system. Therefore, when it is determined that the application is not running substitute classes, it can be inferred that the application is currently running in a customized system.

[0104] As described above, after determining the system in which the application is currently running, the complete classes corresponding to the system can be loaded according to the type of the currently running system to ensure the normal operation of the application.

[0105] In some other embodiments, during the process of determining whether the system on which the application is running is a customized system, the application may have completed the loading of the complete class. If the application has completed the loading of the complete class, it is also possible to determine whether the loaded class contains an identification method through the reflection mechanism, so as to determine whether the system on which the application is currently running is a customized system. Thus, according to the system on which the application is currently running, different running logics can be directly executed based on the loaded complete class to ensure the running of the application.

[0106] It can be understood that when the application starts, classes in the system are usually directly loaded. If there is no corresponding class in the system, classes in the application may be loaded through the application class loader.

[0107] Due to the lag of class loading, although the class loading has been completed, it is impossible to determine the type of the system on which the application is currently running, and thus it is impossible to execute subsequent running logics according to different systems to maintain the running of the application.

[0108] Based on this, it is possible to determine whether the loaded class contains an identification method through the reflection mechanism. If it contains an identification method, it is determined that the loaded class is a substitute class, indicating that the application is currently running on a non-customized system; if it does not contain an identification method, it is determined that the loaded class is a customized class, indicating that the application is currently running on a customized system.

[0109] Furthermore, if the system on which the application is currently running is a customized system, customized logic can be executed subsequently to ensure the running of the application; if the system on which the application is currently running is a non-customized system, compatible logic can be executed subsequently to maintain the running of the application.

[0110] The above method determines whether a substitute class or a customized class is used by judging whether the class called during the running of the application contains an identification method, and then determines the type of the system on which the application is running according to the class called during the running of the application, which is convenient for the application to flexibly switch running logics in different systems. For example, a substitute class is loaded in a non-customized system to ensure the realization of the basic functions of the application, enabling the application to run normally in a wider range of system environments and enhancing the compatibility of the application.

[0111] Regarding the above S102 and the above S103, it can be understood that the above customized system refers to a system that supports customized APIs; the above customized class refers to a class written to adapt to the customized system, which can utilize the special functions and interfaces of the customized system to implement the customized functions in the application.

[0112] Further, when the application runs on a system that supports custom APIs, usually the parent class loader can directly find the original custom class. Once the parent class loader successfully finds and loads the original custom class, the application can instantiate it and create an object of this custom class. Then, by calling the methods of this class and other means, the custom logic can be executed.

[0113] Among them, the above-mentioned custom logic refers to the code logic written and implemented based on a specific custom system or application scenario, with unique functions and behaviors.

[0114] Further, since the above non-custom system does not have the special functions and interfaces of the custom system, it is impossible to directly run the custom class that depends on the custom system to run.

[0115] As mentioned above, in order to ensure the normal operation of the application in the non-custom system, the application class loader can load the substitute class, so as to ensure the normal operation of the application through the substitute class.

[0116] Among them, the above-mentioned substitute class refers to the class created in the application to replace the function of the custom class. The substitute class has the same class structure as the custom class, but its implementation method does not depend on the custom system.

[0117] Further, when the application runs on a system that does not support custom APIs, the parent class loader cannot find the original custom class (because the environment and resources required for this custom class simply do not exist in the system). When both the parent class loaders (i.e., the bootstrap class loader and the extension class loader) cannot find the original custom class, the application's own class loader (i.e., the application class loader) will try to load it by itself. At this time, the application class loader will load the substitute class (i.e., the class written to replace the function of the original custom class in the non-custom system), and ensure the normal operation of the application in the non-custom system through the substitute class.

[0118] Usually, the substitute class can execute compatible logic according to the compatibility requirements of relevant functions to assist the application in running in the non-custom system.

[0119] In a possible implementation, loading the substitute class in the non-custom system to assist the application in running in the non-custom system includes: loading the substitute class in the non-custom system so that the substitute class assists the application in running in the non-custom system according to the compatible logic; among them, the compatible logic refers to the rules followed by the application when running in the non-custom system.

[0120] It can be understood that the above-mentioned compatible logic can include various different processing methods, and the specific processing methods can include: changing the implementation method, running with function degradation, and shielding the corresponding function.

[0121] Among them, the change implementation method refers to implementing functions similar to the original customized class by using other general algorithms, interfaces, or methods instead of relying on the special functions of the customized system.

[0122] Function degradation operation means that when it is impossible to fully implement all the functions of the original customized class, select to implement only some basic functions, or implement the functions with lower performance or quality, and then return the default value, etc.

[0123] Masking the corresponding function means that when some functions cannot be fully implemented or are not suitable for implementation on a non-customized system, an exception can be thrown or other methods can be taken to mask the function, so that the upper-layer logic of the application can capture and handle this situation, such as actively hiding the interface elements related to the function to avoid incorrect user operations.

[0124] For the above method, when the application runs in a non-customized system, by loading the substitute class and running according to the compatibility logic, it can ensure the smooth operation of the application on the non-customized system. In different system environments, the special functions of the customized system often cannot be directly used, and the compatibility logic of the substitute class provides an alternative solution, which can ensure that the core functions of the application are not affected by system differences.

[0125] Figure 3 It is a schematic structural diagram of an operating device of an application provided by an embodiment of the present application.

[0126] Exemplarily, as Figure 3 shown, the device 300 includes:

[0127] A judgment module 301, configured to judge whether the system on which the application is currently running is a customized system when receiving an opening instruction for the application.

[0128] A first loading module 302, configured to load the customized class in the customized system if the system on which the application is currently running is a customized system, so as to execute the customized function corresponding to the customized class during the running of the application.

[0129] A second loading module 303, configured to load the substitute class in the non-customized system if the system on which the application is currently running is a non-customized system, so as to assist the application in running in the non-customized system.

[0130] Among them, the substitute class has the same class structure as the customized class.

[0131] Optionally, the device further includes a creation module, which is specifically configured to: create a substitute class with the same class structure as the customized class in the code corresponding to the application, and add an identification method that differentiates from the customized class in the substitute class.

[0132] In a possible implementation, the determination module is specifically configured to: determine whether the class called by the application during operation is a substitute class; if the class called by the application during operation is a substitute class, determine that the system on which the application is currently running is a non-customized system; if the class called by the application during operation is not a substitute class, determine that the system on which the application is currently running is a customized system.

[0133] In a possible implementation, the determination module includes a substitute class determination unit, and the substitute class determination unit is specifically configured to: determine whether an identification method is included in the class called by the application during operation; wherein, the identification method is a method that differentiates the substitute class from the customized class; if there is an identification method, determine that the class called by the application during operation is a substitute class; if there is no identification method, determine that the class called by the application during operation is not a substitute class.

[0134] In a possible implementation, the device further includes a second determination module, and the second determination module is specifically configured to: determine whether the operation of the application requires calling a customized class; in the case of determining that a customized class needs to be called, determine whether the system on which the application is currently running is a customized system.

[0135] In a possible implementation, the second determination module includes a requirement determination unit, and the requirement determination unit is specifically configured to: obtain the functional requirements corresponding to the application; determine whether the functional requirements depend on the customized functions provided by the customized class; if the functional requirements depend on the customized functions provided by the customized class, determine that the operation of the application requires calling the customized class; if the functional requirements do not depend on the customized functions provided by the customized class, determine that the operation of the application does not require calling the customized class.

[0136] In a possible implementation, the second loading module is specifically configured to: load the substitute class in the non-customized system, so that the substitute class assists the application to run in the non-customized system according to the compatibility logic; wherein, the compatibility logic refers to the rules followed by the application when running in the non-customized system.

[0137] Figure 4 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application.

[0138] Exemplarily, as Figure 4 shown, the electronic device 400 includes: a memory 401 and a processor 402, wherein, an executable program code 4011 is stored in the memory 401, and the processor 402 is configured to call and execute the executable program code 4011 to execute a running method of an application.

[0139] In addition, an embodiment of the present application also protects a device, which may include a memory and a processor. Among them, an executable program code is stored in the memory, and the processor is configured to call and execute the executable program code to execute a running method of an application program provided by an embodiment of the present application.

[0140] In this embodiment, the device may be divided into functional modules according to the above method example. For example, each functional module may correspond, or two or more functions may be integrated into one processing module. The above integrated module may be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is illustrative, only a logical function division, and there may be other division methods in actual implementation.

[0141] In the case of dividing each functional module corresponding to each function, the device may further include a judgment module, a first loading module, a second loading module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be cited in the function description of the corresponding functional module, and will not be repeated here.

[0142] It should be understood that the device provided in this embodiment is used to execute the above-mentioned running method of an application program, so the same effect as the above-mentioned implementation method can be achieved.

[0143] In the case of adopting an integrated unit, the device may include a processing module and a storage module. Among them, when the device is applied to an electronic device, the processing module may be used to control and manage the actions of the electronic device. The storage module may be used to support the electronic device to execute relevant program codes and data, etc.

[0144] Among them, the processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules, and circuits shown in combination with the disclosure of the present application. The processor may also be a combination that realizes computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.

[0145] In addition, the device provided in the embodiment of the present application may specifically be a chip, a component, or a module. The chip may include a processor and a memory connected thereto; among them, the memory is used to store instructions, and when the processor calls and executes the instructions, the chip may execute the running method of an application program provided in the above embodiment.

[0146] This embodiment also provides a computer-readable storage medium, in which computer program code is stored. When the computer program code runs on a computer, the computer is caused to execute the above-related method steps to implement a running method of an application program provided in the above embodiment.

[0147] This embodiment also provides a computer program product. When the computer program product runs on a computer, the computer is caused to execute the above-related steps to implement a running method of an application program provided in the above embodiment.

[0148] Among them, the device, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be elaborated here.

[0149] Through the description of the above embodiments, those skilled in the art can understand that for the convenience and conciseness of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.

[0150] In the embodiments provided in the present application, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection with each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.

[0151] The above content is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, and all should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for running an application program, characterized in that The method includes: When receiving an opening instruction for a corresponding application, determining whether the system on which the application is currently running is a customized system; If the system on which the application is currently running is a customized system, loading the customized classes in the customized system to execute the corresponding customized functions of the customized classes during the running of the application; If the system on which the application is currently running is a non-customized system, loading the substitute classes in the non-customized system to assist the application in running in the non-customized system; wherein, the substitute classes have the same class structure as the customized classes.

2. The method according to claim 1, characterized in that, Before determining whether the system on which the application is currently running is a customized system, the method further includes: Creating substitute classes with the same class structure as the customized classes in the code corresponding to the application, and adding identification methods in the substitute classes that are different from the customized classes.

3. The method according to claim 1, characterized in that, Determining whether the system on which the application is currently running is a customized system includes: Determining whether the class called by the application during running is a substitute class; If the class called by the application during running is a substitute class, determining that the system on which the application is currently running is a non-customized system; If the class called by the application during running is not a substitute class, determining that the system on which the application is currently running is a customized system.

4. The method according to claim 3, characterized in that, Determining whether the class called by the application during running is a substitute class includes: Determining whether the class called by the application during running contains an identification method; wherein, the identification method is the method in the substitute class that is different from the customized class; If there is an identification method, determining that the class called by the application during running is a substitute class; If there is no identification method, determining that the class called by the application during running is not a substitute class.

5. The method according to claim 1, wherein Before determining whether the system on which the application is currently running is a customized system, the method further includes: Determining whether the running of the application needs to call customized classes; When it is determined that customized classes need to be called, performing the determination of whether the system on which the application is currently running is a customized system.

6. The method according to claim 5, characterized in that, Determining whether the running of the application needs to call customized classes includes: Obtaining the functional requirements corresponding to the application; Determining whether the functional requirements depend on the customized functions provided by the customized classes; If the functional requirements depend on the customized functions provided by the customized classes, determining that the running of the application needs to call the customized classes; If the functional requirements do not depend on the customized functions provided by the customized classes, determining that the running of the application does not need to call the customized classes.

7. The method according to claim 1, wherein Loading the substitute classes in the non-customized system to assist the application in running in the non-customized system includes: Loading the substitute classes in the non-customized system so that the substitute classes assist the application in running in the non-customized system according to the compatibility logic; wherein, the compatibility logic refers to the rules followed by the application when running in the non-customized system.

8. An operating device for an application program, characterized in that, The device includes: A judgment module, configured to determine whether the system on which the application is currently running is a customized system when receiving an opening instruction for a corresponding application; A first loading module, configured to load customized classes in the customized system if the system on which the application is currently running is a customized system, so as to execute the customized functions corresponding to the customized classes during the running of the application; A second loading module, configured to load substitute classes in the non-customized system if the system on which the application is currently running is a non-customized system, so as to assist the application in running in the non-customized system; wherein, the substitute classes have the same class structure as the customized classes.

9. An electronic device, characterized in that, The electronic device includes: A memory, configured to store executable program codes; A processor, configured to call and run the executable program codes from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed, implements the method according to any one of claims 1 to 7.