CN108958980A - Prevent method, electronic device and the computer readable storage medium of Activity life cycle exception - Google Patents

Prevent method, electronic device and the computer readable storage medium of Activity life cycle exception Download PDF

Info

Publication number
CN108958980A
CN108958980A CN201810812109.3A CN201810812109A CN108958980A CN 108958980 A CN108958980 A CN 108958980A CN 201810812109 A CN201810812109 A CN 201810812109A CN 108958980 A CN108958980 A CN 108958980A
Authority
CN
China
Prior art keywords
terminated
activity
reason
top portion
life cycle
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810812109.3A
Other languages
Chinese (zh)
Other versions
CN108958980B (en
Inventor
吴庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Oppo Chongqing Intelligent Technology Co Ltd
Original Assignee
Oppo Chongqing Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo Chongqing Intelligent Technology Co Ltd filed Critical Oppo Chongqing Intelligent Technology Co Ltd
Priority to CN201810812109.3A priority Critical patent/CN108958980B/en
Publication of CN108958980A publication Critical patent/CN108958980A/en
Application granted granted Critical
Publication of CN108958980B publication Critical patent/CN108958980B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1438Restarting or rejuvenating

Abstract

A kind of method preventing Activity life cycle exception, electronic device and computer readable storage medium, wherein the method for preventing Activity life cycle exception includes: the state of monitor process;If monitored process has terminated, detect whether to rebuild the process that terminated;The process if reconstruction has terminated forces the Activity for returning to stack top portion carrying out recovery operation, the Activity of recovery is corresponded to the foreground that user interface is shown in terminal.It is abnormal that scheme provided by the present application can solve existing android system caused user interface when AMS not yet has enough time clearing up the related data for the process that terminated.

Description

Prevent the method for Activity life cycle exception, electronic device and computer-readable Storage medium
Technical field
This application involves intelligent terminal field more particularly to a kind of methods for preventing Activity life cycle exception, electricity Sub-device and computer readable storage medium.
Background technique
Activity originally means activity, is one of four big components of android system, it is that one kind may include user circle The component in face is mainly used for showing user interface and human-computer interaction, such as makes a phone call, takes a picture, sending mail or display one A map etc., user complete relevant operation by the user interface interaction that Activity is shown;One App (or process) allows to have Multiple Activity.
Under normal circumstances, after process is killed, interface management person services (Activity Manager Service, AMS) Data relevant to the process can be cleared up.However, the grown-in defects of existing android system are, not yet it is in time for clearly in AMS Reason be killed process related data but the pull-up process.During the pull-up process, since AMS is not to current Activity executes relevant operation, and it is abnormal to result in Activity life cycle, thus make user interface abnormal, though for example, Desktop is so returned to, but clicks the icon on desktop, file or folder without any reaction.
Summary of the invention
The embodiment of the present application provides method, electronic device and the computer that a kind prevents Activity life cycle exception Readable storage medium storing program for executing, to solve existing android system when AMS not yet has enough time clearing up the related data for process of being killed Caused Activity life cycle is abnormal.
The embodiment of the present application first aspect provides a kind of method for preventing Activity life cycle exception, comprising:
The state of monitor process;
If the monitored process has terminated, detect whether to rebuild the process that terminated;
If rebuilding the process that terminated, force the Activity for returning to stack top portion carrying out recovery operation, it will The Activity of the recovery corresponds to the foreground that user interface is shown in terminal.
The embodiment of the present application second aspect provides a kind of electronic device, comprising:
Status monitoring module, the state for monitor process;
Detection module detects whether to rebuild the process that terminated if having terminated for the monitored process;
Force revert module, if for rebuilding the process that terminated forcing that the Activity in stack top portion will be returned Recovery operation is carried out, the Activity of the recovery is corresponded into the foreground that user interface is shown in terminal.
The embodiment of the present application third aspect provides another electronic device, comprising: memory, processor and is stored in described It is real when the processor executes the computer program on memory and the computer program that can run on the processor The method for preventing Activity life cycle exception that existing above-mentioned the embodiment of the present application first aspect provides.
The embodiment of the present application fourth aspect provides a kind of computer readable storage medium, is stored thereon with computer program, When the computer program is executed by processor, that realizes above-mentioned the embodiment of the present application first aspect offer prevents Activity raw The method for ordering period exception.
Therefore the technical solution of the application when reconstruction has terminated process forces that stack top portion will be returned to Activity carries out recovery operation, not yet has enough time clearing up the related data for the process that terminated in AMS with existing android system But the process is rebuild, since AMS does not execute relevant operation to current Activity, user interface is caused to be compared extremely, this The technical solution of application forces the measure of the Activity progress recovery operation to return stack top portion due to taking, it protects It has demonstrate,proved current system always and has had an Activity and be in and restored state, so that the life cycle of Activity is allowed to be in normal, The Activity of recovery is corresponded into the foreground that user interface is shown in terminal.
Detailed description of the invention
Fig. 1 is the method one embodiment flow diagram provided by the present application for preventing user interface exception;
Fig. 2 is another embodiment flow diagram of the method for preventing user interface exception provided by the present application;
Fig. 3 is another embodiment flow diagram of the method for preventing user interface exception provided by the present application;
Fig. 4 is another embodiment flow diagram of the method for preventing user interface exception provided by the present application;
Fig. 5 is electronic device one embodiment structural schematic diagram provided by the present application;
Fig. 6 is another example structure schematic diagram of electronic device provided by the present application.
Specific embodiment
To enable present invention purpose, feature, advantage more obvious and understandable, below in conjunction with the application Attached drawing in embodiment, the technical scheme in the embodiment of the application is clearly and completely described, it is clear that described reality Applying example is only some embodiments of the present application, and not all embodiments.Based on the embodiment in the application, those skilled in the art Member's every other embodiment obtained without making creative work, shall fall in the protection scope of this application.
It should be noted that description and claims of this specification and term " first " in above-mentioned attached drawing, " Two " etc. be to be used to distinguish similar objects, without being used to describe a particular order or precedence order.It should be understood that using in this way Data be interchangeable under appropriate circumstances, so as to embodiments herein described herein can in addition to illustrating herein or Sequence other than those of description is implemented.In addition, term " includes " and " having " and their any deformation, it is intended that cover It covers and non-exclusive includes.
Embodiment one
The embodiment of the present application provides a kind of method for preventing Activity life cycle exception, this prevents Activity life The method of period exception is applied to electronic device, which can be the tool such as smart phone, tablet computer, wearable device The equipment of the standby function of preventing Activity life cycle exception, the operating system of above-mentioned electronic device can be ios, Android, windows system or other operating systems, are not construed as limiting herein.
Referring to Fig. 1, the method for preventing Activity life cycle exception mainly includes the following steps that 101 to step 103:
Step 101, the state of monitor process.
Generally, a process includes creation, ready, execution, obstruction and terminates five states such as (or terminations).Process State can be called by process manager monitors function to obtain, and monitors function when calling, the return value of the parameter obtained Show state of a process.
If step 102, monitored process have terminated, detect whether to rebuild the process that terminated.
By taking android system as an example, the process that terminated is created again, and a scene is not have enough time moving due to AMS Remove or clear up the related data of the process of termination.Therefore, after process termination, a detection can be done, to determine whether weight Build this process that terminated.Specifically, if process manager detects that process creation function is called, and parameter therein is institute State the title or mark of the process of termination, it is determined that this process that terminated is created again.
The process if step 103, reconstruction have terminated forces the Activity for returning to stack top portion carrying out recovery operation, with The Activity of recovery is corresponded into the foreground that user interface is shown in terminal.
It remarks additionally herein to the life cycle of the Activity of android system.The life of so-called Activity Period refers to Activity various states experienced from start to end, that is, turns from a state to another state Become, arrive nothing again from scratch, such a state experienced in the process is just called life cycle.Android is using task (Task) Activity is managed, a task is exactly the one group of Activity being stored in stack set, this stack is referred to as Return to stack.Except irrevocable stack is at sky, always there is an Activity to be in and return to stack top portion, in return stack top portion Activity is in operating status, the Activity only through over recovery (resume) this operation, corresponding user interface The foreground of terminal, user's ability normal use, for example, carrying out human-computer interaction can be just shown in.Rebuild in order to prevent terminated into The generation of user interface exception when journey is forced to restore the Activity for returning to stack top portion in the embodiment of the present application (resume) it operates, before the corresponding user interface of the Activity (i.e. resumed Activity) restored is shown in terminal Platform.
From the exemplary method for preventing Activity life cycle exception of above-mentioned attached drawing 1 it is found that the technical solution of the application When reconstruction has terminated process, forces the Activity that will return to stack top portion to carry out recovery operation, exist with existing android system AMS be not yet in time for cleaning terminated process related data but rebuild the process, since AMS is not to current Activity Relevant operation is executed, user interface is caused to be compared extremely, the technical solution of the application is forced due to taking to return stack top portion Activity carry out recovery operation measure, thus it is guaranteed that current system always have an Activity be in restored shape The Activity of recovery is corresponded to user interface and is shown in terminal by state so that the life cycle of Activity be allowed to be in normal Foreground.
Embodiment two
Attached drawing 2 is the method that Activity life cycle exception is prevented described in another embodiment of the application, specific to wrap Step 201 is included to step 204, detailed description are as follows:
Step 201, the state of monitor process.
Term, concept that step 201 is related to etc. are identical as term, the concept that the step 101 of 1 example of attached drawing is related to etc., Realization process is also identical, can refer to the description of previous embodiment, is not repeated herein.
If step 202, monitored process have terminated, detect whether to rebuild the process that terminated.
Term, concept that step 202 is related to etc. are identical as term, the concept that the step 102 of 1 example of attached drawing is related to etc., Realization process is also identical, can refer to the description of previous embodiment, is not repeated herein.
The process if step 203, reconstruction have terminated, obtains triggering and rebuilds the reason of having terminated process.
Either creation process still rebuilds the process of termination for the first time, can be realized by process creation function, and The value of some parameters in process creation function is practical to may indicate that the reason of triggering creation process, therefore, at the present invention one In embodiment, acquisition triggering is rebuild the reason of having terminated process and be can be by calling process creation function, according to process creation It is any in Activity, broadcast reception device assembly, serviced component or the content supplier's component that the value of parameter includes in function One kind determining that the reason of having terminated process is rebuild in triggering.For example, for the program that Java language is write, In the startProcessLocked function of ActivityManagerServcice.java file, it is called with one The parameter of hostingType, the value of this parameter be exactly service, broadcast, content provider or Activity can be determined according to this parameter and be rebuild the reason of having terminated process, for example, if the value of parameter is Broadcast, then trigger reconstruction terminated process the reason of be to start this component of radio receiver.
If step 204, triggering rebuild terminated process the reason of be starting broadcast reception device assembly, starting serviced component or Start any one in content supplier's component, then will return to stack top portion when removing the related data for process of being killed Activity carries out recovery operation.
By taking Andriod system as an example, Andriod system mainly has radio receiver (Broadcast Receiver), uses Family interface (Activity), the service four big components such as (Service) and content supplier (Content Provider), triggering wound It builds whether the reason of having terminated process starts this four components nothing more than, i.e., whether is starting radio receiver, starting Activity, starting service or starting content supplier.
If due to rebuilding the process that terminated being starting this component of Activity, stack top portion will obviously will be returned to Activity carry out recovery operation, there is no the problems of the life cycle of Activity exception in this case.However, if The reason of having terminated process is rebuild as appointing in starting radio receiver, starting service or starting these three components of content supplier When anticipating a kind of, for background technique, the life of Activity is then likely to occur when removing the related data for process of being killed Period is abnormal.Therefore, rebuild terminated process the reason of for starting radio receiver, starting service or starting content supplier this When any one in three components, the Activity that stack top portion will be returned to when removing the related data for process of being killed is carried out Restore (resume) operation, the corresponding user interface of the Activity (i.e. resumed Activity) restored is shown in terminal Foreground.
From the exemplary method for preventing Activity life cycle exception of above-mentioned attached drawing 2 it is found that the technical solution of the application The reason of having terminated process is rebuild in confirmation triggering to start radio receiver, starting service or starting content supplier etc. three When any one in component, the Activity for returning to stack top portion is restored when removing the related data for process of being killed Operation, with existing android system AMS be not yet in time for cleaning be killed process related data but rebuild should be into Journey causes user interface to be compared extremely, the technical side of the application since AMS does not execute relevant operation to current Activity Case is due to taking the measure for forcing to carry out recovery operation to the Activity for returning to stack top portion, thus it is guaranteed that current system Always there is an Activity to be in and restored state, to allow the life cycle of Activity to be in normal, by recovery Activity corresponds to the foreground that user interface is shown in terminal.
Embodiment three
Attached drawing 3 is the method that Activity life cycle exception is prevented described in another embodiment of the application, specific to wrap Step 301 is included to step 305, detailed description are as follows:
Step 301, the state of monitor process.
Term, concept that step 301 is related to etc. and the step 201 of 2 example of step 101 or attached drawing of 1 example of attached drawing are related to Term, concept etc. it is identical, realize that process is also identical, can refer to the description of previous embodiment, be not repeated herein.
If step 302, monitored process have terminated, detect whether to rebuild the process that terminated.
Term, concept that step 302 is related to etc. and the step 202 of 2 example of step 102 or attached drawing of 1 example of attached drawing are related to Term, concept etc. it is identical, realize that process is also identical, can refer to the description of previous embodiment, be not repeated herein.
The process if step 303, reconstruction have terminated, forbids the process of having terminated to send broadcast message before being terminated.
As previously mentioned, a loophole existing for Android native system is, and if some process is terminated, before being terminated, The process can issue a broadcast message and need itself processing, and AMS can restart the process when the process sends and broadcasts the message. AMS can also handle the work of some data scrubbings after old process is terminated during restarting process, be not carried out at this time Resume returns to the Activity this operation in stack top portion, and then no one of leads to system Activity is to be in Resumed state causes user to use abnormal.Therefore, if the process of having terminated is forbidden to send broadcast message before being terminated, It is not in the above problem.Since broadcast message is to send function by broadcast message to realize, wherein there is an enabled parameter, when The enabled Parameter then can normally send broadcast message when calling the parameter when being set as " enabling ", conversely, if being set as Broadcast message then cannot be sent when calling the parameter when " make cannot ", therefore, as one embodiment of the invention, is forbidden eventually Knot process sends the broadcast message transmission letter that broadcast message can be process manager for broadcast transmission process before being terminated Several enabled parameters is set as making cannot.
Step 304, the process termination notice for waiting the process that terminated.
For process after termination, system can send the process termination notice of the process, and AMS waits the process for the process that terminated whole Knot notice, this is the primary process of android system, is not repeated them here.
Step 305, the process of having terminated process termination notify reach when to return stack top portion Activity execute it is extensive Multiple operation.
After executing recovery operation to the Activity for returning to stack top portion, current system just has the Activity of a reply (i.e. resumed Activity), it is meant that this Activity restored is corresponded to before user interface can be shown in terminal Platform.
From the exemplary method for preventing Activity life cycle exception of above-mentioned attached drawing 3 it is found that the technical solution of the application When confirmation rebuilds and terminated process, broadcast message is sent before being terminated by forbidding rebuilding the process that terminated, and it is existing Android system AMS not yet be in time for cleaning terminated process related data but rebuild the process, since AMS does not have Relevant operation is executed to current Activity and user interface is caused to be compared extremely, the technical solution of the application is directly forbidden eventually Knot process sends broadcast message before being terminated, with the process termination for the process of having terminated notify reach when to return stack top portion Activity execute recovery operation, thus it is guaranteed that current system always have an Activity be in restored state, thus It allows the life cycle of Activity to be in normal, the Activity of recovery is corresponded into the foreground that user interface is shown in terminal.
Example IV
Attached drawing 4 is the method that Activity life cycle exception is prevented described in another embodiment of the application, specific to wrap Step 401 is included to step 406, detailed description are as follows:
Step 401, the state of monitor process.
Term, concept that step 401 is related to etc. and the step 101 of 1 example of attached drawing, the step 201 or attached drawing of 2 example of attached drawing Term, concept that the step 301 of 3 examples is related to etc. are identical, realize that process is also identical, can refer to retouching for previous embodiment It states, is not repeated herein.
If step 402, monitored process have terminated, detect whether to rebuild the process that terminated.
Term, concept that step 402 is related to etc. and the step 102 of 1 example of attached drawing, the step 202 or attached drawing of 2 example of attached drawing Term, concept that the step 302 of 3 examples is related to etc. are identical, realize that process is also identical, can refer to retouching for previous embodiment It states, is not repeated herein.
The process if step 403, reconstruction have terminated, obtains triggering and rebuilds the reason of having terminated process.
Either creation process still rebuilds the process of termination for the first time, can be realized by process creation function, and The value of some parameters in process creation function is practical to may indicate that the reason of triggering creation process, therefore, at the present invention one In embodiment, acquisition triggering is rebuild the reason of having terminated process and be can be by calling process creation function, according to process creation It is any in Activity, broadcast reception device assembly, serviced component or the content supplier's component that the value of parameter includes in function One kind determining that the reason of having terminated process is rebuild in triggering.For example, for the program that Java language is write, In the startProcessLocked function of ActivityManagerServcice.java file, it is called with one The parameter of hostingType, the value of this parameter be exactly service, broadcast, content provider or Activity can be determined according to this parameter and be rebuild the reason of having terminated process, for example, if the value of parameter is Broadcast, then trigger reconstruction terminated process the reason of be to start this component of radio receiver.
If it is starting broadcast reception device assembly that step 404, triggering, which rebuild the reason of having terminated process, forbid to having terminated The related data of process, which executes, removes operation.
As one embodiment of the invention, forbid that the related data for the process of having terminated is executed to remove to operate to pass through process Creation function obtains the title or mark of the process that terminated, and according to the record of title or mark to the process of having terminated, jumps The calling to the process data cleaning function that terminated is crossed to realize.By taking Android as an example, in startProcessLocked function In, if obtaining the terminated title or mark of process by process creation function, discovery currently terminated process in AMS There is the record of a same names or mark, and already existing process has been recorded and has terminated, then exists HandleAppDiedLocked will be called to go to do clearly already existing process record in startProcessLocked function Reason, judged according to parameter hostingtype, do not done in this process handleAppDiedLocked can, i.e., The related data for the process of having terminated is not executed and removes operation.
Step 405 waits the necrology for process of being killed to reach.
For process after termination, system can send the process termination notice of the process, and AMS waits the process for the process that terminated whole Knot notice, this is the primary process of android system, is not repeated them here.
Step 406, the process of having terminated process termination notify reach when to return stack top portion Activity execute it is extensive Multiple operation.
After executing recovery operation to the Activity for returning to stack top portion, current system just has the Activity of a reply (i.e. resumed Activity), it is meant that this Activity restored is corresponded to before user interface can be shown in terminal Platform.
From the exemplary method for preventing Activity life cycle exception of above-mentioned attached drawing 4 it is found that the technical solution of the application When confirmation triggering rebuilds the reason of having terminated process to start this component of radio receiver, forbid the phase to the process of having terminated Data are closed to execute removal operation and the process termination of the process of termination is waited to notify to reach, it is logical in the process termination for the process of having terminated Know and recovery operation is executed to the Activity for returning to stack top portion when arrival, is not yet in time for clearly with existing android system in AMS It manages the related data for the process that terminated but rebuilds the process, led since AMS does not execute relevant operation to current Activity User interface is caused to compare extremely, the technical solution of the application, which forbids executing the related data for the process of having terminated, removes operation, with Recovery operation is executed to the Activity for returning to stack top portion when the process termination for the process of having terminated notifies to reach, thus it is guaranteed that Current system always has Activity to be in have restored state, so that the life cycle of Activity is allowed to be in normal, it will The Activity of recovery corresponds to the foreground that user interface is shown in terminal.
Embodiment five.
Fig. 5 provides a kind of electronic device for the embodiment of the present application.The electronic device can be used for realizing above method embodiment The above-mentioned method for preventing Activity life cycle exception provided.As shown in figure 5, the electronic device mainly includes status monitoring Module 501, detection module 502 and force revert module 503, in which:
Status monitoring module 501, the state for monitor process;
Detection module 502 detects whether to rebuild the process that terminated if having terminated for monitored process;
Force revert module 503, if forcing to carry out the Activity for returning to stack top portion for rebuilding the process that terminated The Activity of recovery is corresponded to the foreground that user interface is shown in terminal by recovery operation.
Optionally, force revert module 502 may include termination reason acquiring unit and the first execution unit, in which:
The reason of terminate reason acquiring unit, the process that terminated described in triggering reconstruction for obtaining;
First execution unit, if for trigger rebuild it is described terminated process the reason of be starting broadcast reception device assembly, Start serviced component or starts any one in content supplier's component, the then related data for process of being killed described in the removal When by it is described return stack top portion Activity carry out recovery operation.
Optionally, force revert module 502 may include termination reason acquiring unit, first forbid unit, wait unit With the second execution unit, in which:
Terminate reason acquiring unit, rebuilds the reason of having terminated process for obtaining triggering;
First forbids unit, if rebuilding the reason of having terminated process for triggering as starting broadcast reception device assembly, prohibits Only the related data for the process of having terminated is executed and removes operation;
Unit is waited, the process termination for the process of having terminated notifies;
Second execution unit, for being held in the necrology arrival for the process of having terminated to the Activity for returning to stack top portion Row recovery operation.
Optionally, first forbids unit to include process acquiring unit and forbid call unit, in which:
Process acquiring unit, for obtaining the title or mark of the process that terminated by process creation function;
Forbid call unit, for according to the title of the process that terminated or the record of mark, skipping to having terminated The calling of process data cleaning function.
Optionally, termination reason acquiring unit may include function calling cell and determination unit, in which:
Function calling cell creates function for calling process;
Determination unit, Activity, radio receiver for including according to the value of parameter in the process creation function Any one in component, serviced component or content supplier's component, determine triggering rebuild it is described terminated process the reason of.
Force revert module 502 may include second forbidding unit, waiting unit and the second execution unit, in which:
Second forbids unit, for forbidding the process of having terminated to send broadcast message before being terminated;
Unit is waited, for waiting the process termination for the process that terminated to notify;
Second execution unit, for when the process termination of the process that terminated notifies to reach to returning to stack top portion Activity executes recovery operation.
It should be noted that the division of each functional module is only to lift in the embodiment of the exemplary electronic device of figure 5 above Example explanation, can according to need in practical application, such as the convenient of realization of configuration requirement or software of corresponding hardware considers, And be completed by different functional modules above-mentioned function distribution, i.e., the internal structure of electronic device is divided into different function moulds Block, to complete all or part of the functions described above.Moreover, in practical applications, the corresponding function in the present embodiment Module can be by corresponding hardware realization, can also execute corresponding software by corresponding hardware and complete.This specification provides Each embodiment all can apply foregoing description principle, repeat no more below.
The detailed process of the respective function of each Implement of Function Module, refers to above-mentioned side in electronic device provided in this embodiment Particular content described in method embodiment, details are not described herein again.
Therefore the embodiment of the present application rebuild terminated process when, force by return stack top portion Activity into Row recovery operation, not yet has enough time clearing up the related data for the process that terminated with existing android system in AMS but reconstruction should Process causes user interface to be compared extremely, the technology of the application since AMS does not execute relevant operation to current Activity Scheme is due to taking the measure for forcing to carry out recovery operation to the Activity for returning to stack top portion, thus it is guaranteed that current system System always has an Activity in state has been restored, to allow the life cycle of Activity to be in normal, by recovery Activity corresponds to the foreground that user interface is shown in terminal.
Embodiment six
The embodiment of the present application provides a kind of electronic device, referring to Fig. 6, the electronic device includes:
Memory 601, processor 602 and it is stored in the computer journey that can be run on memory 601 and on processor 602 Sequence, when processor 602 executes the computer program, realizing prevents Activity life cycle described in preceding method embodiment Abnormal method.
Further, the electronic device further include:
At least one input equipment 603 and at least one output equipment 606.
Above-mentioned memory 601, processor 602, input equipment 603 and output equipment 606, are connected by bus 605.
Wherein, input equipment 603 concretely camera, touch panel, physical button or mouse etc..Output equipment 606 concretely display screens.
Memory 601 can be high random access memory body (RAM, Random Access Memory) memory, It can be non-labile memory (non-volatile memory), such as magnetic disk storage.Memory 601 is for storing one Group executable program code, processor 602 are coupled with memory 601.
Further, the embodiment of the present application also provides a kind of computer readable storage medium, the computer-readable storages Medium can be in the electronic device being set in the various embodiments described above, which can be earlier figures 6 Memory in illustrated embodiment.It is stored with computer program on the computer readable storage medium, which is held by processor The method that Activity life cycle exception is prevented described in preceding method embodiment is realized when row.Further, the calculating Machine can storage medium can also be USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), RAM, magnetic disk or The various media that can store program code such as person's CD.
In several embodiments provided herein, it should be understood that disclosed device and method can pass through it Its mode is realized.For example, the apparatus embodiments described above are merely exemplary, for example, the division of the module, only Only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple module or components can be tied Another system is closed or is desirably integrated into, or some features can be ignored or not executed.Another point, it is shown or discussed Mutual coupling, direct-coupling or communication connection can be through some interfaces, the INDIRECT COUPLING or logical of device or module Letter connection can be electrical property, mechanical or other forms.
The module as illustrated by the separation member may or may not be physically separated, aobvious as module The component shown may or may not be physical module, it can and it is in one place, or may be distributed over multiple On network module.Some or all of the modules therein can be selected to realize the mesh of this embodiment scheme according to the actual needs 's.
It, can also be in addition, can integrate in a processing module in each functional module in each embodiment of the application It is that modules physically exist alone, can also be integrated in two or more modules in a module.Above-mentioned integrated mould Block both can take the form of hardware realization, can also be realized in the form of software function module.
If the integrated module is realized in the form of software function module and sells or use as independent product When, it can store in a computer readable storage medium.Based on this understanding, the technical solution of the application is substantially The all or part of the part that contributes to existing technology or the technical solution can be in the form of software products in other words It embodies, which is stored in a readable storage medium storing program for executing, including some instructions are used so that a meter It calculates machine equipment (can be personal computer, server or the network equipment etc.) and executes each embodiment the method for the application All or part of the steps.And readable storage medium storing program for executing above-mentioned includes: USB flash disk, mobile hard disk, ROM, RAM, magnetic or disk etc. The various media that can store program code.
It should be noted that for the various method embodiments described above, describing for simplicity, therefore, it is stated as a series of Combination of actions, but those skilled in the art should understand that, the application is not limited by the described action sequence because According to the application, certain steps can use other sequences or carry out simultaneously.Secondly, those skilled in the art should also know It knows, the embodiments described in the specification are all preferred embodiments, and related actions and modules might not all be this Shen It please be necessary.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, there is no the portion being described in detail in some embodiment Point, it may refer to the associated description of other embodiments.
The above are to the method for preventing Activity life cycle exception, electronic device and computer provided herein The description of readable storage medium storing program for executing, for those skilled in the art, according to the thought of the embodiment of the present application, in specific embodiment And there will be changes in application range, to sum up, the contents of this specification should not be construed as limiting the present application.

Claims (15)

1. a kind of method for preventing Activity life cycle exception characterized by comprising
The state of monitor process;
If the monitored process has terminated, detect whether to rebuild the process that terminated;
If rebuilding the process that terminated, force the Activity for returning to stack top portion carrying out recovery operation, it will be described extensive Multiple Activity corresponds to the foreground that user interface is shown in terminal.
2. the method according to claim 1 for preventing Activity life cycle exception, which is characterized in that the pressure will The Activity for returning to stack top portion carries out recovery operation, and the Activity of the recovery is corresponded to user interface and is shown in terminal Foreground, comprising:
Obtain the reason of process has been terminated described in triggering reconstruction;
If the reason of process that terminated described in triggering reconstruction is starting broadcast reception device assembly, starting serviced component or starting content Any one in provider's component, then by the stack top portion that returns when the related data for process of being killed described in the removal Activity carries out recovery operation.
3. the method according to claim 1 for preventing Activity life cycle exception, which is characterized in that the pressure will The Activity for returning to stack top portion carries out recovery operation, and the Activity of the recovery is corresponded to user interface and is shown in terminal Foreground, comprising:
Obtain the reason of process has been terminated described in triggering reconstruction;
If the reason of process that terminated described in triggering reconstruction is starting broadcast reception device assembly, forbid to the process that terminated Related data execute remove operation;
Wait the process termination notice of the process that terminated;
It notifies to execute the Activity for returning to stack top portion when reaching in the process termination of the process that terminated and restores behaviour Make.
4. the method according to claim 3 for preventing Activity life cycle exception, which is characterized in that described to forbid pair The related data of the process that terminated, which executes, removes operation, comprising:
The title or mark of the process that terminated are obtained by process creation function;
According to the record of title or mark to the process that terminated, the tune to the process data cleaning function that terminated is skipped With.
5. the method according to claim 2 or 3 for preventing Activity life cycle exception, which is characterized in that described to obtain Take the reason of process has been terminated described in triggering reconstruction, comprising:
Calling process creates function;
Activity that value according to parameter in the process creation function includes, broadcast reception device assembly, serviced component or interior Hold any one in provider's component, determines the reason of having terminated process described in triggering reconstruction.
6. the method according to claim 1 for preventing Activity life cycle exception, which is characterized in that the pressure will The Activity for returning to stack top portion carries out recovery operation, and the Activity of the recovery is corresponded to user interface and is shown in terminal Foreground, comprising:
The process that terminated is forbidden to send broadcast message before being terminated;
Wait the process termination notice of the process that terminated;
It notifies to execute the Activity for returning to stack top portion when reaching in the process termination of the process that terminated and restores behaviour Make.
7. the method according to claim 6 for preventing Activity life cycle exception, which is characterized in that described to forbid institute It states the process of termination and sends broadcast message before being killed, comprising:
The enabled parameter that the broadcast message of broadcast transmission process sends function is set as making by process manager cannot.
8. a kind of electronic device characterized by comprising
Status monitoring module, the state for monitor process;
Detection module detects whether to rebuild the process that terminated if having terminated for the monitored process;
Force revert module, if forcing to carry out the Activity for returning to stack top portion extensive for rebuilding the process that terminated Multiple operation, corresponds to the foreground that user interface is shown in terminal for the Activity of the recovery.
9. electronic device according to claim 8, which is characterized in that the force revert module includes:
The reason of terminate reason acquiring unit, the process that terminated described in triggering reconstruction for obtaining;
First execution unit, if for trigger rebuild it is described terminated process the reason of be starting broadcast reception device assembly, starting Any one in serviced component or starting content supplier's component, then when related data for process of being killed described in the removal, will The Activity for returning to stack top portion carries out recovery operation.
10. electronic device according to claim 8, which is characterized in that the force revert module includes:
The reason of terminate reason acquiring unit, the process that terminated described in triggering reconstruction for obtaining;
First forbids unit, if for trigger rebuild it is described terminated process the reason of for starting broadcast reception device assembly, prohibit Only the related data of the process that terminated is executed and removes operation;
Unit is waited, for waiting the process termination notice of the process that terminated;
Second execution unit notifies when reaching for the process termination in the process that terminated to the return stack top portion Activity executes recovery operation.
11. electronic device according to claim 10, which is characterized in that described first forbids the unit to include:
Process acquiring unit, for obtaining the title or mark of the process that terminated by process creation function;
Forbid call unit, for skipping to the process of having terminated according to the title of the process that terminated or the record of mark The calling of data scrubbing function.
12. electronic device according to claim 9 or 10, which is characterized in that the termination reason acquiring unit includes:
Function calling cell creates function for calling process;
Determination unit, Activity, broadcast reception device assembly for including according to the value of parameter in the process creation function, Any one in serviced component or content supplier's component, determine triggering rebuild it is described terminated process the reason of.
13. electronic device according to claim 8, which is characterized in that the force revert module includes:
Second forbids unit, for forbidding the process that terminated to send broadcast message before being terminated;
Unit is waited, the process termination for the process that terminated notifies;
Second execution unit, for returning to stack top portion to described in the necrology arrival of the process that terminated Activity executes recovery operation.
14. a kind of electronic device, comprising: memory, processor and be stored on the memory and can be on the processor The computer program of operation, which is characterized in that when the processor executes the computer program, realize in claim 1 to 7 Any one the method.
15. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program When being executed by processor, any one the method in claim 1 to 7 is realized.
CN201810812109.3A 2018-07-23 2018-07-23 Method for preventing Activity life cycle from being abnormal, electronic device and computer readable storage medium Active CN108958980B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810812109.3A CN108958980B (en) 2018-07-23 2018-07-23 Method for preventing Activity life cycle from being abnormal, electronic device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810812109.3A CN108958980B (en) 2018-07-23 2018-07-23 Method for preventing Activity life cycle from being abnormal, electronic device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN108958980A true CN108958980A (en) 2018-12-07
CN108958980B CN108958980B (en) 2021-07-09

Family

ID=64463412

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810812109.3A Active CN108958980B (en) 2018-07-23 2018-07-23 Method for preventing Activity life cycle from being abnormal, electronic device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN108958980B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109614105A (en) * 2018-12-13 2019-04-12 南开大学 A kind of Android application return stack state static simulation method of Starting mode sensitivity
CN111858224A (en) * 2019-04-25 2020-10-30 珠海格力电器股份有限公司 Process monitoring method and device in android system
CN113268284A (en) * 2021-06-01 2021-08-17 广州欢网科技有限责任公司 Implementation method and device for quickly releasing internal memory of android APP and computer equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103064750A (en) * 2012-12-25 2013-04-24 北京奇虎科技有限公司 Interrupt restoring method and device for browser control
CN103309771A (en) * 2013-06-14 2013-09-18 厦门雅迅网络股份有限公司 Method for realizing boot quick recovery of application program based on Android system
CN106095621A (en) * 2016-06-12 2016-11-09 Tcl集团股份有限公司 The restoration methods of Launcher operation exception and system in a kind of Android system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103064750A (en) * 2012-12-25 2013-04-24 北京奇虎科技有限公司 Interrupt restoring method and device for browser control
CN103309771A (en) * 2013-06-14 2013-09-18 厦门雅迅网络股份有限公司 Method for realizing boot quick recovery of application program based on Android system
CN106095621A (en) * 2016-06-12 2016-11-09 Tcl集团股份有限公司 The restoration methods of Launcher operation exception and system in a kind of Android system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
码农向前冲: "Android开发进阶:Activity和进程的回收和状态恢复", 《HTTPS://WWW.JIANSHU.COM/P/72CCB08E7F34》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109614105A (en) * 2018-12-13 2019-04-12 南开大学 A kind of Android application return stack state static simulation method of Starting mode sensitivity
CN109614105B (en) * 2018-12-13 2022-02-15 南开大学 Starting mode sensitive Android application return stack state static simulation method
CN111858224A (en) * 2019-04-25 2020-10-30 珠海格力电器股份有限公司 Process monitoring method and device in android system
CN113268284A (en) * 2021-06-01 2021-08-17 广州欢网科技有限责任公司 Implementation method and device for quickly releasing internal memory of android APP and computer equipment

Also Published As

Publication number Publication date
CN108958980B (en) 2021-07-09

Similar Documents

Publication Publication Date Title
CN108958980A (en) Prevent method, electronic device and the computer readable storage medium of Activity life cycle exception
CN109710394A (en) Timing task processing system and method
CN102831035A (en) Information backup method and device
CN108334415A (en) A kind of fault-tolerance processing method, device, terminal and storage medium
CN104346279A (en) Method and device for software testing
CN109614168A (en) Memory Optimize Method and device
CN110245020B (en) Mobile phone content forensics method and system based on multiple forensics devices
CN104965731B (en) A kind of data processing method and electric terminal
CN108664521B (en) Method and device for providing serial number, electronic equipment and readable storage medium
CN103870319B (en) Information processing method, device and electronic equipment
CN109656783A (en) System platform monitoring method and device
CN111143170A (en) Cloud mobile phone monitoring system and method
CN113452772A (en) Intelligent scene processing method and device, storage medium and electronic equipment
CN106569917A (en) Data backup method and mobile terminal
CN108366098A (en) A kind of data interactive method and device of network node
CN108471612A (en) SIM card falls card restoration methods, device and terminal
CN102073523A (en) Method and device for implementing software version synchronization
CN103377071B (en) A kind of batch data delet method and system
CN106067857A (en) A kind of user of preventing is forced the method and device rolled off the production line
CN106201464A (en) A kind of application icon processing method freezing application and mobile terminal
CN113127113A (en) Response method of operation instruction and computer equipment
CN111722850A (en) Method, device and system for processing application among multiple systems
CN111367648A (en) Resource allocation method and device
CN105930224B (en) Dump operation control method, device and terminal
CN109542841A (en) The method and terminal device of data snapshot are created in cluster

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant