A method for dynamically loading algorithms in Android applications

By splitting the algorithm main program and model files in Android applications into SO dynamic link library files and independent model files, dynamic loading solves the problems of large application size and inconvenient updates, achieving reduced size and improved functional flexibility.

CN112596821BActive Publication Date: 2024-10-01NANJING GOLDEN SHIELD PUBLIC SAFETY TECH RES INST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110092425.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-24
Publication Date
2024-10-01
Estimated Expiration
2041-01-24

AI Technical Summary

Technical Problem

The integration of algorithm SDK in Android applications results in excessively large application size and inconvenient algorithm updates, which affects user experience and function integration.

Method used

By splitting the algorithm main program and model files into independent SO dynamic link library files and algorithm model files, and saving them on the server, they can be downloaded from the server and loaded dynamically when needed to achieve dynamic loading of the algorithm and avoid the traditional method. The overall packaging and updating of SDK files is difficult.

Benefits of technology

It greatly reduces the size of Android applications, supports flexible switching of algorithm functions, and enhances user experience and update convenience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112596821B_ABST
    Figure CN112596821B_ABST
Patent Text Reader

Abstract

The present invention proposes a method for dynamically loading an algorithm in an Android application, comprising the following steps: S1, modifying the algorithm main program so that the algorithm can dynamically load an algorithm model file; S2, encapsulating the algorithm main program as an algorithm SO file; S3, saving the algorithm SO file and the algorithm model file to a server, and when the algorithm needs to be used, the Android application downloads the algorithm SO file and the algorithm model file from the server, calls the algorithm SO file through the Android application, and dynamically loads the algorithm model file through the algorithm SO file, thereby realizing dynamic loading of the algorithm. The present invention splits the algorithm main program and the algorithm model file into an independent SO algorithm dynamic link library file and an extracted algorithm model file, and stores the SO algorithm dynamic link library file and the algorithm model file in a designated directory of a mobile terminal storage space, respectively, instead of encapsulating and integrating the entire algorithm main program and the algorithm model file in an Android application like an SDK, which greatly reduces the size of the Android application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of use of Android application algorithms, and in particular to a method for dynamically loading algorithms in Android applications. Background Art

[0002] With the development of communication and computer technology, the use of smart terminals such as mobile phones is becoming more and more widespread, the functions of mobile applications are becoming more and more abundant, and various artificial intelligence functions can be realized through integrated algorithms.

[0003] At present, when Android mobile applications need to integrate algorithm capabilities, they often need to embed the algorithm SDK (Software Development Kit) and model files into the application during the application development process and package them together with the main application program. If the application needs to integrate multiple algorithm capabilities, it is necessary to embed the SDK and model files of multiple algorithms. The size of the SDK and model files of a single algorithm is often around hundreds of megabytes. In this case, the size of the packaged Android mobile application will be abnormally large, affecting users' download and use, and it is not convenient for algorithm updates and the integration of new algorithm capabilities. Summary of the invention

[0004] In order to solve the above technical problems, the present invention proposes a method for dynamically loading algorithms in Android applications, aiming to solve the problem that the current Android application integrates algorithm SDK, resulting in large application volume and inconvenient algorithm update, so that Android applications can dynamically load algorithms. The method for dynamically loading algorithms in Android applications of the present invention comprises the following steps:

[0005] S1, modify the algorithm main program to enable the algorithm to dynamically load the algorithm model file;

[0006] S2, encapsulate the algorithm main program into an algorithm SO file;

[0007] S3, save the algorithm SO file and algorithm model file to the server. When the algorithm needs to be used, the Android application downloads the algorithm SO file and algorithm model file from the server, calls the algorithm SO file through the Android application, and dynamically loads the algorithm model file through the algorithm SO file, thereby realizing dynamic loading of the algorithm.

[0008] Specifically, the method for dynamically loading an algorithm in an Android application of the present invention comprises the following steps:

[0009] A1. Modify the main algorithm program to enable the algorithm to dynamically load the algorithm model file;

[0010] The traditional method is to package the algorithm main program and the algorithm model file into an SDK file. The present invention extracts the algorithm model file from the SDK file separately and stores the extracted algorithm model file in a specified directory of the mobile phone storage space.

[0011] Modify the algorithm main program so that it can load the separately extracted algorithm model file from the specified directory of the mobile phone storage space;

[0012] A2, compile the algorithm main program into an algorithm dynamic link library file;

[0013] A21, for the new algorithm main program, directly use the compiler software to compile the algorithm main program into an SO dynamic link library file;

[0014] A22. For the algorithm main program that already exists in the form of SDK file, compiler software is used to split the SDK file, and the files that can be changed in the SDK file format are compiled into SO dynamic link library files. The files that cannot be changed in the SDK file format are loaded into the SO dynamic link library file in the form of middleware, thereby solving the technical problem that the algorithm main program that already exists in the form of SDK file cannot be modified into SO dynamic link library file.

[0015] SDK (Software Development Kit) is a software development kit, which is a common technology for the existing Android system to call third-party programs. It belongs to the existing technology. The present invention does not make any innovation to the SDK technology, so it will not be repeated here.

[0016] SO (Shared Object, SO) is a dynamic link library file, which is a technology for calling third-party programs. The present invention does not make any innovations to the SO technology, but only adopts the form of SO dynamic link library files. The working principle and working method of SO dynamic link library files will not be repeated here.

[0017] Algorithm: refers to an accurate and complete description of a solution to a problem, which is a series of clear instructions for solving the problem. The algorithm of the present invention refers to a series of clear instructions for solving the problem applied to the Android system;

[0018] Algorithm model file: an algorithm model refers to a problem-solving step that integrates a series of clear instructions for solving a problem. The algorithm model file of the present invention refers to a file applied to an Android system that integrates a series of problem-solving steps that integrate clear instructions for solving a problem.

[0019] Middleware: a type of software between the application system and the system software. It uses the basic services (functions) provided by the system software to connect the various parts of the application system or different applications on the network, and can achieve the purpose of resource sharing and function sharing. The middleware of the present invention refers to the use of middleware to enable the loading of files in the form of SDK files in the SO dynamic link library file.

[0020] A3, saving the algorithm SO file and the algorithm model file to the server;

[0021] Copy the SO algorithm dynamic link library file and the separately extracted algorithm model file to the server;

[0022] The server includes a self-built server and a cloud server, and the server is a service application installed in the server that can provide file downloads;

[0023] A4, integrating the functional functions of the algorithm in the Android application;

[0024] In the Android application, according to the download interface of the server, write the download code to obtain the download code to download the SO algorithm dynamic link library file and the algorithm model file from the server;

[0025] In the Android application, according to the interface specification of the SO algorithm dynamic link library file in step A3, write the calling code and obtain the calling code so as to call after downloading the SO algorithm dynamic link library file;

[0026] The download code refers to the code that realizes downloading the SO algorithm dynamic link library file and the algorithm model file from the server;

[0027] The calling code refers to the code that can call the SO algorithm dynamic link library file;

[0028] The Android application refers to the application installed on the Android phone that ultimately calls the algorithm function; referred to as APP;

[0029] A5, the Android application calls the download interface of the server when running, and downloads the algorithm SO file and the algorithm model file to the storage space of the mobile terminal;

[0030] The Android application downloads the code at runtime, calls the download interface of the server, downloads the SO algorithm dynamic link library file and the algorithm model file from the server, and downloads the algorithm SO file and the algorithm model file to a specified directory of the storage space of the mobile terminal;

[0031] A6, the Android application dynamically loads the algorithm SO file and the algorithm model file downloaded from the server by calling the code and using the interface specification of the SO algorithm dynamic link library file using JAVA native call (Java Native Interface, JNI) technology at runtime;

[0032] A7, the Android application implements the corresponding functions of the algorithm through the algorithm SO file and the algorithm model file.

[0033] Beneficial effect: Compared with the traditional method of embedding the algorithm SDK into the Android application and packaging them together, the present invention supports Android applications to dynamically load algorithm programs, and supports saving the algorithm SO file and the algorithm model file to the server. When the algorithm function needs to be used, the algorithm SO file and the algorithm model file are downloaded from the server and loaded to implement the algorithm function. This method greatly reduces the size of Android applications, supports switching algorithm functions according to needs, and enhances user experience.

[0034] The present invention splits the algorithm main program and algorithm model files into independent SO algorithm dynamic link library files and extracted algorithm model files, and stores the SO algorithm dynamic link library files and algorithm model files in a specified directory of the mobile phone terminal storage space respectively, instead of encapsulating and integrating the entire algorithm main program and algorithm model files in the Android application like the SDK method, thereby greatly reducing the size of the Android application.

[0035] For the scenario of multiple algorithm main programs, the present invention also proposes a method for dynamic algorithm loading in an Android application applied to multiple algorithm main programs, comprising the following steps:

[0036] B1, for multiple algorithm main programs, modify each algorithm main program so that the algorithm can dynamically load the algorithm model file;

[0037] The traditional method is to package the algorithm main program and the algorithm model file into an SDK file. The present invention extracts the algorithm model file from the SDK file separately and stores the extracted algorithm model file in a specified directory of the mobile phone storage space.

[0038] Modify the algorithm main program so that it can load the separately extracted algorithm model file from the specified directory of the mobile phone storage space;

[0039] B2, compile each algorithm main program into an algorithm dynamic link library file;

[0040] B21, for the new algorithm main program, directly use the compiler software to compile the algorithm main program into an SO dynamic link library file;

[0041] B22. For the algorithm main program that already exists in the form of SDK file, the SDK file is split using compilation software, and the files that can be changed in the SDK file format are compiled into SO dynamic link library files. The files that cannot be changed in the SDK file format are loaded into the SO dynamic link library file in the form of middleware, thereby solving the technical problem that the algorithm main program that already exists in the form of SDK file cannot be modified into SO dynamic link library file.

[0042] SDK (Software Development Kit) is a software development kit, which is a common technology for the existing Android system to call third-party programs. It belongs to the existing technology. The present invention does not make any innovation to the SDK technology, so it will not be repeated here.

[0043] SO (Shared Object, SO) is a dynamic link library file, which is a technology for calling third-party programs. The present invention does not make any innovations to the SO technology, but only adopts the form of SO dynamic link library files. The working principle and working method of SO dynamic link library files will not be repeated here.

[0044] Algorithm: refers to an accurate and complete description of a solution to a problem, which is a series of clear instructions for solving the problem. The algorithm of the present invention refers to a series of clear instructions for solving the problem applied to the Android system;

[0045] Algorithm model file: an algorithm model refers to a problem-solving step that integrates a series of clear instructions for solving a problem. The algorithm model file of the present invention refers to a file applied to an Android system that integrates a series of problem-solving steps that integrate clear instructions for solving a problem.

[0046] Middleware: a type of software between the application system and the system software. It uses the basic services (functions) provided by the system software to connect the various parts of the application system or different applications on the network, and can achieve the purpose of resource sharing and function sharing. The middleware of the present invention refers to the use of middleware to enable the loading of files in the form of SDK files in the SO dynamic link library file.

[0047] B3, saving each algorithm SO file and each algorithm model file to the server;

[0048] Copy the SO algorithm dynamic link library file and the separately extracted algorithm model file to the server;

[0049] The server includes a self-built server and a cloud server, and the server is a service application installed in the server that can provide file downloads;

[0050] B4, integrate the functional functions of each algorithm in the Android application;

[0051] In the Android application, according to the download interface of the server, write the download code to obtain the download code to download the SO algorithm dynamic link library file and the algorithm model file from the server;

[0052] In the Android application, according to the interface specification of the SO algorithm dynamic link library file in step A3, write the calling code and obtain the calling code so as to call after downloading the SO algorithm dynamic link library file;

[0053] The download code refers to the code that realizes downloading the SO algorithm dynamic link library file and the algorithm model file from the server;

[0054] The calling code refers to the code that can call the SO algorithm dynamic link library file;

[0055] The Android application refers to the application installed on the Android phone that ultimately calls the algorithm function; referred to as APP;

[0056] B5, the Android application calls different download interfaces of the server when running, and downloads the algorithm SO file and the algorithm model file to the storage space of the mobile terminal as needed;

[0057] The Android application manually selects the download code as needed during operation, calls the download interface of the server, downloads the SO algorithm dynamic link library file and the algorithm model file from the server as needed, and downloads the algorithm SO file and the algorithm model file to a specified directory of the mobile terminal storage space;

[0058] The Android application dynamically loads the algorithm SO file and the algorithm model file downloaded from the server by calling the code and using the interface specification of the SO algorithm dynamic link library file using the JAVA native call (Java Native Interface, JNI) technology at runtime;

[0059] B6, the Android application implements the corresponding functions of the algorithm through the algorithm SO file and the algorithm model file.

[0060] B7, the Android application switches the calling code to switch different algorithm SO files and different algorithm model files to achieve flexible switching of different algorithm corresponding functions.

[0061] Beneficial effect: Compared with the traditional method of embedding the algorithm SDK into the Android application and packaging them together, the present invention supports Android applications to dynamically load algorithm programs, and supports saving the algorithm SO file and the algorithm model file to the server. When the algorithm function needs to be used, the algorithm SO file and the algorithm model file are downloaded from the server and loaded to implement the algorithm function. This method greatly reduces the size of Android applications, supports switching algorithm functions according to needs, and enhances user experience.

[0062] The present invention splits the algorithm main program and algorithm model files into independent SO algorithm dynamic link library files and extracted algorithm model files, and stores the SO algorithm dynamic link library files and algorithm model files in a specified directory of the mobile phone terminal storage space respectively, instead of encapsulating and integrating the entire algorithm main program and algorithm model files in the Android application like the SDK method, thereby greatly reducing the size of the Android application. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Figure 1 It is a schematic diagram of the process of the present invention;

[0064] Figure 2 An example diagram of dynamic algorithm loading for the Android application of the present invention. DETAILED DESCRIPTION

[0065] Embodiment 1: A method for dynamically loading algorithms in Android applications is intended to solve the problem that the current Android application SDK is integrated with the algorithm, resulting in large application volume and inconvenient algorithm update, so that Android applications can dynamically load algorithms. The method for dynamically loading algorithms in Android applications of the present invention comprises the following steps:

[0066] S1, modify the algorithm main program so that the algorithm main program can dynamically load the algorithm model file;

[0067] S2, encapsulate the algorithm main program into an algorithm SO file;

[0068] S3, save the algorithm SO file and algorithm model file to the server. When the algorithm needs to be used, the Android application downloads the algorithm SO file and algorithm model file from the server, calls the algorithm SO file through the Android application, and dynamically loads the algorithm model file through the algorithm SO file, thereby realizing dynamic loading of the algorithm.

[0069] The present invention splits the algorithm main program and algorithm model files into independent SO algorithm dynamic link library files and extracted algorithm model files, and stores the SO algorithm dynamic link library files and algorithm model files in a specified directory of the mobile phone terminal storage space respectively, instead of encapsulating and integrating the entire algorithm main program and algorithm model files in the Android application like the SDK method, thereby greatly reducing the size of the Android application.

[0070] Example 2: Figure 1 As shown, the method for dynamically loading algorithms in Android applications of the present invention comprises the following steps:

[0071] A1. Modify the main algorithm program so that it can dynamically load the algorithm model file;

[0072] The traditional method is to package the algorithm main program and the algorithm model file into an SDK file. The present invention extracts the algorithm model file from the SDK file separately and stores the extracted algorithm model file in a specified directory of the mobile phone storage space.

[0073] Modify the algorithm main program so that it can load the separately extracted algorithm model file from the specified directory of the mobile phone storage space;

[0074] A2, compile the algorithm main program into an algorithm dynamic link library file;

[0075] A21, for the new algorithm main program, directly use the compiler software to compile the algorithm main program into an SO dynamic link library file;

[0076] A22. For the algorithm main program that already exists in the form of SDK file, compiler software is used to split the SDK file, and the files that can be changed in the SDK file format are compiled into SO dynamic link library files. The files that cannot be changed in the SDK file format are loaded into the SO dynamic link library file in the form of middleware, thereby solving the technical problem that the algorithm main program that already exists in the form of SDK file cannot be modified into SO dynamic link library file.

[0077] SDK (Software Development Kit) is a software development kit, which is a common technology for the existing Android system to call third-party programs. It belongs to the existing technology. The present invention does not make any innovation to the SDK technology, so it will not be repeated here.

[0078] SO (Shared Object, SO) is a dynamic link library file, which is a technology for calling third-party programs. The present invention does not make any innovations to the SO technology, but only adopts the form of SO dynamic link library files. The working principle and working method of SO dynamic link library files will not be repeated here.

[0079] Algorithm: refers to an accurate and complete description of a solution to a problem, which is a series of clear instructions for solving the problem. The algorithm of the present invention refers to a series of clear instructions for solving the problem applied to the Android system;

[0080] Algorithm model file: an algorithm model refers to a problem-solving step that integrates a series of clear instructions for solving a problem. The algorithm model file of the present invention refers to a file applied to an Android system that integrates a series of problem-solving steps that integrate clear instructions for solving a problem.

[0081] Middleware: a type of software between the application system and the system software. It uses the basic services (functions) provided by the system software to connect the various parts of the application system or different applications on the network, and can achieve the purpose of resource sharing and function sharing. The middleware of the present invention refers to the use of middleware to enable the loading of files in the form of SDK files in the SO dynamic link library file.

[0082] A3, saving the algorithm SO file and the algorithm model file to the server;

[0083] Copy the SO algorithm dynamic link library file and the separately extracted algorithm model file to the server;

[0084] The server includes a self-built server and a cloud server, and the server is a service application installed in the server that can provide file downloads;

[0085] A4, integrating the functional functions of the algorithm in the Android application;

[0086] In the Android application, according to the download interface of the server, write the download code to obtain the download code to download the SO algorithm dynamic link library file and the algorithm model file from the server;

[0087] In the Android application, according to the interface specification of the SO algorithm dynamic link library file in step A3, write the calling code and obtain the calling code so as to call after downloading the SO algorithm dynamic link library file;

[0088] The download code refers to the code that realizes downloading the SO algorithm dynamic link library file and the algorithm model file from the server;

[0089] The calling code refers to the code that can call the SO algorithm dynamic link library file;

[0090] The Android application refers to the application installed on the Android phone that ultimately calls the algorithm function; referred to as APP;

[0091] A5, the Android application calls the download interface of the server when running, and downloads the algorithm SO file and the algorithm model file to the storage space of the mobile terminal;

[0092] When the corresponding algorithm is used for the first time, the Android application calls the download interface of the server to download the algorithm SO file and the algorithm model file to the storage space of the mobile terminal;

[0093] The Android application downloads the code at runtime, calls the download interface of the server, downloads the SO algorithm dynamic link library file and the algorithm model file from the server, and downloads the algorithm SO file and the algorithm model file to a specified directory of the storage space of the mobile terminal;

[0094] A6, the Android application dynamically loads the algorithm SO file and the algorithm model file downloaded from the server by calling the code and using the interface specification of the SO algorithm dynamic link library file using JAVA native call (Java Native Interface, JNI) technology at runtime;

[0095] A7, the Android application implements the corresponding functions of the algorithm through the algorithm SO file and the algorithm model file.

[0096] like Figure 2 As shown, the Android application loads the algorithm SO file to load the algorithm model file, thereby realizing the corresponding functions of the algorithm.

[0097] Compared with the traditional way of embedding the algorithm SDK into the Android application and packaging them together, the present invention supports Android applications to dynamically load algorithm programs, and supports saving the algorithm SO file and algorithm model file to the server. When the algorithm function needs to be used, the algorithm SO file and algorithm model file are downloaded from the server and loaded to implement the algorithm function. This method greatly reduces the size of Android applications, supports switching algorithm functions according to needs, and enhances user experience.

[0098] The present invention splits the algorithm main program and algorithm model files into independent SO algorithm dynamic link library files and extracted algorithm model files, and stores the SO algorithm dynamic link library files and algorithm model files in a specified directory of the mobile phone terminal storage space respectively, instead of encapsulating and integrating the entire algorithm main program and algorithm model files in the Android application like the SDK method, thereby greatly reducing the size of the Android application.

[0099] Embodiment 3: For the scenario of multiple algorithm main programs, the present invention also proposes a method for dynamically loading algorithms in an Android application for multiple algorithm main programs, comprising the following steps:

[0100] B1, for multiple algorithm main programs, modify each algorithm main program so that each algorithm main program can dynamically load the algorithm model file;

[0101] The traditional method is to package the algorithm main program and the algorithm model file into an SDK file. The present invention extracts the algorithm model file from the SDK file separately and stores the extracted algorithm model file in a specified directory of the mobile phone storage space.

[0102] Modify the algorithm main program so that it can load the separately extracted algorithm model file from the specified directory of the mobile phone storage space;

[0103] B2, compile each algorithm main program into an algorithm dynamic link library file;

[0104] B21, for the new algorithm main program, directly use the compiler software to compile the algorithm main program into an SO dynamic link library file;

[0105] B22. For the algorithm main program that already exists in the form of SDK file, the SDK file is split using compilation software, and the files that can be changed in the SDK file format are compiled into SO dynamic link library files. The files that cannot be changed in the SDK file format are loaded into the SO dynamic link library file in the form of middleware, thereby solving the technical problem that the algorithm main program that already exists in the form of SDK file cannot be modified into SO dynamic link library file.

[0106] SDK (Software Development Kit) is a software development kit, which is a common technology for the existing Android system to call third-party programs. It belongs to the existing technology. The present invention does not make any innovation to the SDK technology, so it will not be repeated here.

[0107] SO (Shared Object, SO) is a dynamic link library file, which is a technology for calling third-party programs. The present invention does not make any innovations to the SO technology, but only adopts the form of SO dynamic link library files. The working principle and working method of SO dynamic link library files will not be repeated here.

[0108] Algorithm: refers to an accurate and complete description of a solution to a problem, which is a series of clear instructions for solving the problem. The algorithm of the present invention refers to a series of clear instructions for solving the problem applied to the Android system;

[0109] Algorithm model file: an algorithm model refers to a problem-solving step that integrates a series of clear instructions for solving a problem. The algorithm model file of the present invention refers to a file applied to an Android system that integrates a series of problem-solving steps that integrate clear instructions for solving a problem.

[0110] Middleware: a type of software between the application system and the system software. It uses the basic services (functions) provided by the system software to connect the various parts of the application system or different applications on the network, and can achieve the purpose of resource sharing and function sharing. The middleware of the present invention refers to the use of middleware to enable the loading of files in the form of SDK files in the SO dynamic link library file.

[0111] B3, saving each algorithm SO file and each algorithm model file to the server;

[0112] Copy the SO algorithm dynamic link library file and the separately extracted algorithm model file to the server;

[0113] The server includes a self-built server and a cloud server, and the server is a service application installed in the server that can provide file downloads;

[0114] B4, integrate the functional functions of each algorithm in the Android application;

[0115] In the Android application, according to the download interface of the server, write the download code to obtain the download code to download the SO algorithm dynamic link library file and the algorithm model file from the server;

[0116] In the Android application, according to the interface specification of the SO algorithm dynamic link library file in step A3, write the calling code and obtain the calling code so as to call after downloading the SO algorithm dynamic link library file;

[0117] The download code refers to the code that realizes downloading the SO algorithm dynamic link library file and the algorithm model file from the server;

[0118] The calling code refers to the code that can call the SO algorithm dynamic link library file;

[0119] The Android application refers to the application installed on the Android phone that ultimately calls the algorithm function; referred to as APP;

[0120] B5, the Android application calls different download interfaces of the server when running, and downloads the algorithm SO file and the algorithm model file to the storage space of the mobile terminal as needed;

[0121] The Android application manually selects the download code as needed during operation, calls the download interface of the server, downloads the SO algorithm dynamic link library file and the algorithm model file from the server as needed, and downloads the algorithm SO file and the algorithm model file to a specified directory of the mobile terminal storage space;

[0122] The Android application dynamically loads the algorithm SO file and the algorithm model file downloaded from the server by calling the code and using the interface specification of the SO algorithm dynamic link library file using the JAVA native call (Java Native Interface, JNI) technology at runtime;

[0123] B6, the Android application implements the corresponding functions of the algorithm through the algorithm SO file and the algorithm model file.

[0124] B7, the Android application switches the calling code to switch different algorithm SO files and different algorithm model files to achieve flexible switching of different algorithm corresponding functions.

[0125] Embodiment 4: For the scenario of multiple algorithm main programs, the present invention also proposes a method for dynamically loading algorithms in an Android application for multiple algorithm main programs, comprising the following steps:

[0126] B1, for multiple algorithm main programs, modify each algorithm main program so that each algorithm main program can dynamically load the algorithm model file;

[0127] The traditional method is to package the algorithm main program and the algorithm model file into an SDK file. The present invention extracts the algorithm model file from the SDK file separately and stores the extracted algorithm model file in a specified directory of the mobile phone storage space.

[0128] Modify the algorithm main program so that it can load the separately extracted algorithm model file from the specified directory of the mobile phone storage space;

[0129] B2, compile each algorithm main program into an algorithm dynamic link library file;

[0130] B21, for the new algorithm main program, directly use the compiler software to compile the algorithm main program into an SO dynamic link library file;

[0131] B22. For the algorithm main program that already exists in the form of SDK file, the SDK file is split using compilation software, and the files that can be changed in the SDK file format are compiled into SO dynamic link library files. The files that cannot be changed in the SDK file format are loaded into the SO dynamic link library file in the form of middleware, thereby solving the technical problem that the algorithm main program that already exists in the form of SDK file cannot be modified into SO dynamic link library file.

[0132] SDK (Software Development Kit) is a software development kit, which is a common technology for the existing Android system to call third-party programs. It belongs to the existing technology. The present invention does not make any innovation to the SDK technology, so it will not be repeated here.

[0133] SO (Shared Object, SO) is a dynamic link library file, which is a technology for calling third-party programs. The present invention does not make any innovations to the SO technology, but only adopts the form of SO dynamic link library files. The working principle and working method of SO dynamic link library files will not be repeated here.

[0134] Algorithm: refers to an accurate and complete description of a solution to a problem, which is a series of clear instructions for solving the problem. The algorithm of the present invention refers to a series of clear instructions for solving the problem applied to the Android system;

[0135] Algorithm model file: an algorithm model refers to a problem-solving step that integrates a series of clear instructions for solving a problem. The algorithm model file of the present invention refers to a file applied to an Android system that integrates a series of problem-solving steps that integrate clear instructions for solving a problem.

[0136] Middleware: a type of software between the application system and the system software. It uses the basic services (functions) provided by the system software to connect the various parts of the application system or different applications on the network, and can achieve the purpose of resource sharing and function sharing. The middleware of the present invention refers to the use of middleware to enable the loading of files in the form of SDK files in the SO dynamic link library file.

[0137] B3, saving each algorithm SO file and each algorithm model file to the server;

[0138] Copy the SO algorithm dynamic link library file and the separately extracted algorithm model file to the server;

[0139] The server includes a self-built server and a cloud server, and the server is a service application installed in the server that can provide file downloads;

[0140] B4, integrate the functional functions of each algorithm in the Android application;

[0141] In the Android application, according to the download interface of the server, write the download code to obtain the download code to download the SO algorithm dynamic link library file and the algorithm model file from the server;

[0142] In the Android application, according to the interface specification of the SO algorithm dynamic link library file in step A3, write the calling code and obtain the calling code so as to call after downloading the SO algorithm dynamic link library file;

[0143] The download code refers to the code that realizes downloading the SO algorithm dynamic link library file and the algorithm model file from the server;

[0144] The calling code refers to the code that can call the SO algorithm dynamic link library file;

[0145] The Android application refers to the application installed on the Android phone that ultimately calls the algorithm function; referred to as APP;

[0146] B5, the Android application calls different download interfaces of the server when running, and downloads the algorithm SO file and the algorithm model file to the storage space of the mobile terminal as needed;

[0147] Furthermore, the Android application is also integrated with a code number, and the server is provided with a correspondence table between the code number and the SO algorithm dynamic link library file and the algorithm model file.

[0148] When the Android application is running, it first searches the table corresponding to the code number and the SO algorithm dynamic link library file and the algorithm model file on the server side according to the code number, searches for the SO algorithm dynamic link library file and the algorithm model file corresponding to the code number according to the code number, and then calls the download interface of the server side to download the corresponding SO algorithm dynamic link library file and the algorithm model file from the server side as needed, and downloads the corresponding algorithm SO file and the algorithm model file to the specified directory of the storage space of the mobile terminal;

[0149] The Android application dynamically loads the algorithm SO file and the algorithm model file downloaded from the server by calling the code and using the interface specification of the SO algorithm dynamic link library file using the JAVA native call (Java Native Interface, JNI) technology at runtime;

[0150] B6, the Android application implements the corresponding functions of the algorithm through the algorithm SO file and the algorithm model file.

[0151] B7, the Android application switches the calling code to switch different algorithm SO files and different algorithm model files to achieve flexible switching of different algorithm corresponding functions.

Claims

1. A method for dynamically loading algorithms in an Android application, characterized in that The steps include: B1, for multiple algorithm main programs, modify each algorithm main program so that the algorithm main program can dynamically load the algorithm model file; Extract the algorithm model file from the SDK file separately, and store the extracted algorithm model file in the specified directory of the mobile phone storage space; Modify the algorithm main program so that it can load the separately extracted algorithm model file from the specified directory of the mobile phone storage space; B2, compile each algorithm main program into an algorithm dynamic link library file; B21, for the new algorithm main program, directly use the compiler software to compile the algorithm main program into the SO algorithm dynamic link library file; B22, for the algorithm main program that already exists in the form of SDK file, use the compiler software to split the SDK file, compile the files that can change the form of SDK file into SO algorithm dynamic link library file, and load the files that cannot change the form of SDK file in the SO algorithm dynamic link library file through the form of middleware; B3, saving each SO algorithm dynamic link library file and each algorithm model file to the server; Copy the SO algorithm dynamic link library file and the separately extracted algorithm model file to the server; The server includes a self-built server and a cloud server, and the server is a service application installed in the server that can provide file downloads; B4, integrate the functional functions of each algorithm in the Android application; In the Android application, according to the download interface of the server, write the download code to obtain the download code to download the SO algorithm dynamic link library file and the algorithm model file from the server; In the Android application, according to the interface specification of the SO algorithm dynamic link library file, write the calling code and obtain the calling code so as to call it after downloading the SO algorithm dynamic link library file; B5, the Android application calls different download interfaces of the server when running, and downloads the SO algorithm dynamic link library file and the algorithm model file to the storage space of the mobile terminal as needed; The Android application manually selects the download code as needed during operation, calls the download interface of the server, downloads the SO algorithm dynamic link library file and the algorithm model file from the server as needed, and downloads the SO algorithm dynamic link library file and the algorithm model file to a specified directory of the mobile terminal storage space; The Android application dynamically loads the SO algorithm dynamic link library file and the algorithm model file downloaded from the server by calling the code and using the interface specification of the SO algorithm dynamic link library file using JAVA local call JNI technology during runtime; B6, the Android application implements the corresponding algorithm functions through the SO algorithm dynamic link library file and the algorithm model file; B7, the Android application switches the calling code to switch between different SO algorithm dynamic link library files and different algorithm model files to achieve flexible switching of the corresponding functions of different algorithms.

2. The method for dynamically loading algorithms in Android applications according to claim 1, characterized in that : In step B22, the middleware is in the form of intermediate software so that the file in the form of SDK file can be loaded in the SO algorithm dynamic link library file.

3. The method for dynamically loading algorithms in Android applications according to claim 1, characterized in that : In step B4, the download code is a code for downloading the SO algorithm dynamic link library file and the algorithm model file from the server; the calling code refers to the code written to call the SO algorithm dynamic link library file; the Android application is an APP application installed on an Android phone that ultimately calls the algorithm function.

4. The method for dynamically loading algorithms in Android applications according to claim 1, characterized in that : The Android application is also integrated with a code number, and the server is provided with a corresponding table between the code number and the SO algorithm dynamic link library file and the algorithm model file; When the Android application is running, it first searches the corresponding table of the server-side code number and the SO algorithm dynamic link library file and the algorithm model file according to the code number, searches for the SO algorithm dynamic link library file and the algorithm model file corresponding to the code number according to the code number, and then calls the download interface of the server to download the corresponding SO algorithm dynamic link library file and the algorithm model file from the server as needed, and downloads the corresponding SO algorithm dynamic link library file and the algorithm model file to the specified directory of the storage space of the mobile terminal.