Specific implementation mode
Below in conjunction with attached drawing in the embodiment of the present invention, technical solution in the embodiment of the present invention carries out clear, complete
Ground describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Usually exist
The component of the embodiment of the present invention described and illustrated in attached drawing can be arranged and be designed with a variety of different configurations herein.Cause
This, the detailed description of the embodiment of the present invention to providing in the accompanying drawings is not intended to limit claimed invention below
Range, but it is merely representative of the selected embodiment of the present invention.Based on the embodiment of the present invention, those skilled in the art are not doing
The every other embodiment obtained under the premise of going out creative work, shall fall within the protection scope of the present invention.
It should be noted that:Similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi
It is defined, then it further need not be defined and explained in subsequent attached drawing in a attached drawing.Meanwhile the present invention's
In description, term " first ", " second " etc. are only used for distinguishing description, are not understood to indicate or imply relative importance.
A kind of tune of multi-process provided in an embodiment of the present invention plays method and is applied in Android system, leads in the Android system
Multiple application programs are often installed, when each application program runs offer service, the process that is required to is application providing system
Resource so that application program can normal operation provide related service to the user.But in actual use, if electronics is set
Standby, such as mobile phone, opening many applications with the period will cause mobile phone EMS memory insufficient, so cell phone system in order to guarantee section it is important
Process can trouble-free operation, relatively unessential process will be killed by force, such as the downloading process on backstage.Due to the downloading process on backstage
Compared to the process for interface display, priority and significance level are lower, therefore in the case of limited system resources, it will
Preferentially killed by force.Since process is by after strong kill, system will limit the process again by self-starting, therefore be brought to user bad
User experience.The embodiment of the present invention provides a kind of tune of multi-process method as a result, by mutually tying up the service of each process
It is fixed, with the mutual supervision between realization process, the process killed by force by system has been adjusted with timely, has restored service in time, and then improve
The experience sense of user.
A kind of tune of multi-process provided in an embodiment of the present invention plays method and is applied to terminal device, is installed on the terminal device
There is Android system, then readily comprehensible, which may be, but not limited to, the smart electronics such as tablet computer, smart mobile phone
Equipment.Fig. 1 is please referred to, is a kind of structural schematic diagram of terminal device 100 provided in an embodiment of the present invention, the terminal device 100
Tune lifting device 110, memory 120, storage control 130, processor 140, Peripheral Interface 150, input including multi-process are defeated
Go out unit 160, audio unit 170 and display unit 180.
The memory 120, storage control 130, processor 140, Peripheral Interface 150, input-output unit 160, sound
Frequency unit 170,180 each element of display unit are directly or indirectly electrically connected between each other, to realize the transmission or friendship of data
Mutually.It is electrically connected for example, these elements can be realized between each other by one or more communication bus or signal wire.The multi-process
Tune lifting device 110 include that at least one can be stored in the memory 120 in the form of software or firmware (firmware)
Or it is solidificated in the software function module in the operating system (operating system, OS) of the terminal device 100.The place
Reason device 140 is used to execute the executable module stored in memory 120, such as the tune lifting device 110 of the multi-process includes
Software function module or computer program.
Wherein, memory 120 may be, but not limited to, random access memory (Random Access Memory,
RAM), read-only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read-Only
Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only Memory, EPROM),
Electricallyerasable ROM (EEROM) (Electric Erasable Programmable Read-Only Memory, EEPROM) etc..
Wherein, memory 120 is for storing program, and the processor 140 executes described program, this hair after receiving and executing instruction
The method performed by terminal device 100 that the stream process that bright embodiment any embodiment discloses defines can be applied to processor
In 140, or realized by processor 140.
Processor 140 may be a kind of IC chip, the processing capacity with signal.Above-mentioned processor 140 can
To be general processor, including central processing unit (Central Processing Unit, abbreviation CPU), network processing unit
(Network Processor, abbreviation NP) etc.;Can also be digital signal processor (DSP), application-specific integrated circuit (ASIC),
Field programmable gate array (FPGA) either other programmable logic device, discrete gate or transistor logic, discrete hard
Part component.It may be implemented or execute disclosed each method, step and the logic diagram in the embodiment of the present invention.General processor
Can be microprocessor or the processor 140 can also be any conventional processor 140 etc..
The Peripheral Interface 150 couples various input/output devices to processor 140 and memory 120.At some
In embodiment, Peripheral Interface 150, processor 140 and storage control 130 can be realized in one single chip.Other one
In a little examples, they can be realized by independent chip respectively.
The interaction that input-output unit 160 is used to that user input data to be supplied to realize user and terminal device 100.It is described
Input-output unit 160 may be, but not limited to, mouse and keyboard etc..
Audio unit 170 provides a user audio interface, may include that one or more microphones, one or more raises
Sound device and voicefrequency circuit.
Display unit 180 provides an interactive interface (such as user interface) between terminal device 100 and user
Or it is referred to user for display image data.In the present embodiment, the display unit 180 can be liquid crystal display or touch
Control display.Can be that the capacitance type touch control screen or resistance-type of single-point and multi-point touch operation is supported to touch if touch control display
Control screen etc..Single-point and multi-point touch operation is supported to refer to touch control display and can sense on the touch control display one or more
The touch control operation generated simultaneously at a position, and transfer to processor 140 to be calculated and handled the touch control operation that this is sensed.
Fig. 2 is please referred to, is a kind of flow diagram for having adjusted method of multi-process provided in an embodiment of the present invention, this method
Including:
Step S110 triggers host process.
Specifically, the host process is process for interface display, there are two types of the trigger means are general, the row of user is responded
For or Android system behavior trigger host process.As when the user clicks " pp assistant "
When the icon of this application program, it will triggering host process, or when the end for being equipped with " pp assistant " application program
When end equipment is networked by no net state connection as there is net state, host process will be also triggered.
Step S120, the host process call the described first primary API to start first service.
The first primary API is the primary application programming interfaces startService that Android system provides, wherein API
Full name be Application Program Interface, Chinese translation is application programming interfaces.I other words the host process
StartService will be called to start first service.
Step S130, the first service call the described first primary API to start second service, and the Android system root
The process where the second service is played according to the mapping relations tune between the service stated in advance and process.
Specifically, after first service starts, the first primary API will be called to start second service, it should be noted that this
One service and second service are located in the different processes of same application, so that can be by respective between multiple processes
Service is bound and is supervised.In turn, which will be according to the mapping relations tune between the service stated in advance and process
The process where second service is played, i other words, which will state the process at place in advance, then after second service starts,
The Android system is by the process where having adjusted second service therewith.
Step S140, the first service call the described second primary API to bind the second service, and monitor described the
The connection disconnected event of two services.
Wherein, the second primary API is the primary application programming interfaces bindService that Android system provides.I other words
After second service starts, which will call the bindService to bind second service, and second is bound in first service
When service, " onServiceDisconnected " that generates second service is connected into disconnected event, then, the first service is also
The connection disconnected event of second service is monitored by ServiceConnection interfaces.
Step S150, when the connection disconnected event of the second service is triggered, the first service calls described the
One primary API starts the second service, and the Android system is by according to the correspondence for the service and process stated in advance,
The process where the second service is adjusted.
Specifically, when the connection disconnected event of second service is triggered, the process where showing the second service is
System kills by force, and since first service and second service have been set up binding relationship, then timely monitoring is obtained second by first service
Service is killed by force.In turn, first service will re-call the first primary API startups second service, which also will
According to the correspondence of the service and process stated in advance, the process where second service has been adjusted so where second service
Process resumption, second service are able to normal operation, ensure that user experience.
It can be seen that due to mutual indepedent between each process, therefore process can not be bound, but to each process
Service is bound, and by the supervision to service state, has reached the supervision to each process status, to work as one of process
When being killed by force, the service in another process can carry out " rescue " to the service of binding rapidly.
Step S160, the first service calls the second primary API to bind the second service again, and supervises again
Listen the connection disconnected event of the second service.
In order to ensure the long-term supervision of first service and second service, when the process where second service is killed by force, first
Service is by starting second service, and after making the process where Android system tune second service, first service should also weigh
New binding second service, continues to monitor with the succeeding state to second service.Specifically, first service calling second is primary
API binds second service again, and monitors second service by ServiceConnection interfaces
" onServiceDisconnected " connects disconnected event.
Other than first service can be bound and be monitored to second service, second service can also to first service into
Row binding and monitoring, to realize the two-way supervision between first service and second service.The second service carries out first service
Binding and monitoring are executed after first service starts second service, and Fig. 3 is specifically please referred to, and are provided in an embodiment of the present invention another
A kind of flow diagram for having adjusted method of multi-process, this method include:
Step S210 triggers host process.
Specifically, the host process is process for interface display, there are two types of the trigger means are general, the row of user is responded
For or Android system behavior trigger host process.When such as the icon of " pp assistant " this application program when the user clicks, it will touch
Host process is sent out, or has net state when the terminal device for being equipped with " pp assistant " application program networks to become by no net state connection
When, it will also trigger host process.
Step S220, the host process call the described first primary API to start first service.
The first primary API is the primary application programming interfaces startService that Android system provides, wherein API
Full name be Application Program Interface, Chinese translation is application programming interfaces.I other words the host process
StartService will be called to start first service.
Step S230, the first service call the described first primary API to start second service, and the Android system root
The process where the second service is played according to the mapping relations tune between the service stated in advance and process.
Specifically, after first service starts, the first primary API will be called to start second service, it should be noted that this
One service and second service are located in the different processes of same application, so that can be by respective between multiple processes
Service is bound and is supervised.In turn, which will be according to the mapping relations tune between the service stated in advance and process
The process where second service is played, i other words, which will state the process at place in advance, then after second service starts,
The Android system is by the process where having adjusted second service therewith.
Step S240, the second service call the described second primary API to bind the first service, and monitor described the
The connection disconnected event of one service.
I other words after second service startup, it, should while first service calls the second primary API bindings second service
Second service will also call the second primary API bindings first service, and monitor the first clothes by ServiceConnection interfaces
" onServiceDisconnected " of business connects disconnected event.
Step S250, when the connection disconnected event of the first service is triggered, the second service calls described the
One primary API starts the first service, and the Android system will be corresponding with process according to the service stated in advance
Relationship has adjusted the process where the first service.
Specifically, when the connection disconnected event of first service is triggered, show the process where first service by system
It kills by force, then the second service will re-call the first primary API startups first service, and then the Android system will be according to pre- first sign
The correspondence of bright service and process, has adjusted the process where first service, to ensure the normal operation of first service, improves
User experience.
Step S260, the second service calls the second primary API to bind the first service again, and supervises again
Listen the connection disconnected event of the first service.
Similarly it is found that in order to ensure that second service can supervise the state of first service for a long time, the second service is first
Secondary startup first service, and after the process where Android system tune first service, second service should also re-call second
Primary API binds first service again, and first service is monitored to continue through ServiceConnection interfaces
" onServiceDisconnected " connects disconnected event.
It can be seen that this programme, by the binding between different services, the mutual keep-alive between realization process solves certain
A process is killed by force by system, due to being unable to the problem of self-starting causes corresponding service to be suspended, improves user experience.This
Outside, startup and binding between being serviced in this programme are all made of primary API, and there is no simultaneous caused by cell phone manufacturer's custom-built system
Capacitive problem, has widened application range.
As another embodiment, a kind of tune of multi-process provided in an embodiment of the present invention rise method be not only applicable to it is double
Between process, it may also be used between multiple processes.It is illustrated by taking three processes as an example, such as includes the first process, the second process
With third process, the first process corresponding with service A, the second process corresponding with service B, third process corresponding with service C, specially:
If after the first process initiation service A, service A, which starts, services B, service B startup services C (or service A startup services
C), corresponding second processes of service B, the corresponding third processes of service C and have been adjusted therewith.In turn, service A bindings service B and right
The connection disconnected event of service B is monitored, and service B bindings service C simultaneously monitors the connection disconnected event for servicing C, takes
Business C bindings service A simultaneously monitors the connection disconnected event for servicing A.Then when the connection disconnected event quilt of any one service
When triggering, the service for being responsible for monitoring will all restart the service, and system will adjust the corresponding process of the service, be responsible for monitoring
Service also carries out re-starting binding in order to continue to monitor within the subsequent period.
Another way, the first process initiation service A, and service A starts service B, and service B starts service C, and adjusts therewith
Service corresponding second processes of B, the corresponding third processes of service C.And then it services A bindings service B and the connection for servicing B is disconnected
Event is monitored, and service A bindings service C simultaneously monitors the connection disconnected event for servicing C, and service C bindings service A is simultaneously right
The connection disconnected event of service A is monitored.When the connection disconnected event of one or two of service B or service C is triggered
When, for service A by restarting service B and/or service C, system will adjust service B and/or the corresponding processes of service C, lay equal stress on
Newly bound.It is readily comprehensible, when the connection disconnected event for servicing B and service C is concurrently triggered, also i other words, service B
When being killed by force simultaneously with the process where service C, service A need not start service B and service C, selectively
Only start one, specific implementation mode can self-defined setting as needed.
It should be noted that only illustratively listing the binding method between multiple processes herein, form is bound
It is varied, it can be configured according to actual needs.
Fig. 3 is please referred to, is a kind of function module signal of the tune lifting device 110 of multi-process provided in an embodiment of the present invention
Figure, the device include trigger module 111, the first starting module 112, the second starting module 113, first monitoring module 114, first
Calling module 115, the first binding module 116, second monitor module 117, the second calling module 118 and the second binding module
119。
Trigger module 111, for triggering host process.
In embodiments of the present invention, step S110 and step S210 can be executed by trigger module 111.
First starting module 112 calls the described first primary API to start first service for the host process.
In embodiments of the present invention, step S120 and step S220 can be executed by the first starting module 112.
Second starting module 113 calls the described first primary API to start second service, and institute for the first service
Android system is stated according to the process where the mapping relations tune between the service and process the stated in advance second service.
In embodiments of the present invention, step S130 and step S230 can be executed by the second starting module 113.
First monitors module 114, and the company for the second service that binding relationship is established with first service is monitored for first service
Disconnected event is connect, the first service and second service are located at the different processes of same application.
In embodiments of the present invention, step S140 can be executed by the first monitoring module 114.
First calling module 115, for when the connection disconnected event of the second service is triggered, the first service
The described first primary API is called to start the second service, and the Android system will be according to the service and process stated in advance
Correspondence, adjusted the process where the second service.
In embodiments of the present invention, step S150 can be executed by the first calling module 115.
First binding module 116 calls the second primary API to bind second clothes again for the first service
Business, and the connection disconnected event of the second service is monitored again.
In embodiments of the present invention, step S160 can be executed by the first binding module 116.
Second monitors module 117, calls the described second primary API to bind the first service for the second service,
And monitor the connection disconnected event of the first service.
In embodiments of the present invention, step S240 can be executed by the second monitoring module 117.
Second calling module 118, for when the connection disconnected event of the first service is triggered, the second service
Call the described first primary API to start the first service, and the Android system by according to the service stated in advance with
The correspondence of process has adjusted the process where the first service.
In embodiments of the present invention, step S250 can be executed by the second calling module 118.
Second binding module 119 calls the second primary API to bind first clothes again for the second service
Business, and the connection disconnected event of the first service is monitored again.
In embodiments of the present invention, step S260 can be executed by the second binding module 119.
Due to being had been described in playing method in the tune of multi-process, details are not described herein.
The embodiment of the present invention further discloses a kind of computer readable storage medium, is stored thereon with computer program, described
Computer program realizes that the tune of multi-process provided in an embodiment of the present invention plays method when being executed by processor 140.
In conclusion a kind of tune of multi-process provided in an embodiment of the present invention plays method, apparatus, terminal device and computer
Storage medium, the tune of the multi-process play method and are applied to Android system, and the primary API of Android system setting includes first primary
The primary API of API and second are equipped with multiple application programs on the Android system, and each application program corresponds to multiple processes, each
Multiple services are run in process.This method includes:First service monitoring and first service establish the second service of binding relationship
Disconnected event is connected, first service and second service are located at the different processes of same application, when the connection of second service disconnects thing
When part is triggered, first service calls the first primary API to start second service, and Android system will be according to the service stated in advance
With the correspondence of process, the process where second service has been adjusted.
It can be seen that in the present solution, by different processes first service and second service establish binding relationship, with realize
The mutual supervision of first service and second service, if the connection disconnected event of one of service is triggered, another service
The service will be restarted and adjusted the process where it, to realize the keep-alive of process.Due to being the mutual binding between service
And supervision so that once a side service where process killed by force, another party's service can quick response, to guarantee fast velocity modulation
The process where the service killed by force is played, user experience is improved.
In several embodiments provided herein, it should be understood that disclosed device and method can also pass through
Other modes are realized.The apparatus embodiments described above are merely exemplary, for example, the flow chart in attached drawing and block diagram
Show the device of multiple embodiments according to the present invention, the architectural framework in the cards of method and computer program product,
Function and operation.In this regard, each box in flowchart or block diagram can represent the one of a module, section or code
Part, a part for the module, section or code, which includes that one or more is for implementing the specified logical function, to be held
Row instruction.It should also be noted that at some as in the realization method replaced, the function of being marked in box can also be to be different from
The sequence marked in attached drawing occurs.For example, two continuous boxes can essentially be basically executed in parallel, they are sometimes
It can execute in the opposite order, this is depended on the functions involved.It is also noted that every in block diagram and or flow chart
The combination of box in a box and block diagram and or flow chart can use function or the dedicated base of action as defined in executing
It realizes, or can be realized using a combination of dedicated hardware and computer instructions in the system of hardware.
In addition, each function module in each embodiment of the present invention can integrate to form an independent portion
Point, can also be modules individualism, can also two or more modules be integrated to form an independent part.
It, can be with if the function is realized and when sold or used as an independent product in the form of software function module
It is stored in a computer read/write memory medium.Based on this understanding, technical scheme of the present invention is substantially in other words
The part of the part that contributes to existing technology or the technical solution can be expressed in the form of software products, the meter
Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be
People's computer, server or network equipment etc.) it performs all or part of the steps of the method described in the various embodiments of the present invention.
And storage medium above-mentioned includes:USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited
The various media that can store program code such as reservoir (RAM, Random Access Memory), magnetic disc or CD.It needs
Illustrate, herein, relational terms such as first and second and the like be used merely to by an entity or operation with
Another entity or operation distinguish, and without necessarily requiring or implying between these entities or operation, there are any this realities
The relationship or sequence on border.Moreover, the terms "include", "comprise" or its any other variant are intended to the packet of nonexcludability
Contain, so that the process, method, article or equipment including a series of elements includes not only those elements, but also includes
Other elements that are not explicitly listed, or further include for elements inherent to such a process, method, article, or device.
In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including the element
Process, method, article or equipment in there is also other identical elements.
The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this field
For art personnel, the invention may be variously modified and varied.All within the spirits and principles of the present invention, any made by repair
Change, equivalent replacement, improvement etc., should all be included in the protection scope of the present invention.It should be noted that:Similar label and letter exist
Similar terms are indicated in following attached drawing, therefore, once being defined in a certain Xiang Yi attached drawing, are then not required in subsequent attached drawing
It is further defined and is explained.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.