Processing exception in android thread
AssigneeHuizhou Tcl Mobile Communication Co., Ltd.
InventorDongjiao Tang
Life of this patent
Estimating the term…
Abstract
The present application provides a method for processing an exception in an Android thread, a terminal, and a computer readable storage medium. The method includes: in response to the exception occurring in a sub-thread, calling a custom handler to process the exception; and in response to the exception occurring in a main thread, restarting a message loop of a looper after the message loop is stop, and capturing the exception in the main thread.
Claims17
A method for processing an exception in an Android thread, comprising:
- in response to the exception occurring in a sub-thread, calling a custom handler to process the exception;
- and
- in response to the exception occurring in a main thread, restarting a message loop of a looper after the message loop is stopped, and capturing the exception in the main thread;
- wherein the calling of the custom handler comprises:
- creating the custom handler to define a callback method of the custom handler, wherein the callback method of the custom handler does not terminate a process in which a thread having an exception is located;
- and
- overlaying a first default thread exception handler of an Android system by using the custom handler;
- wherein the first default thread exception handler is configured to terminate the process in which the thread having the exception is located.
A terminal comprising:
- a processor and a computer readable storage medium communicatively connected to the processor, wherein the computer readable storage medium stores thereon instructions executable by the processor to perform operations comprising:
- in response to an exception occurring in a sub-thread, calling a custom handler to process the exception;
- and
- in response to an exception occurring in a main thread, restarting a message loop of a looper after the message loop is stopped, and capturing the exception in the main thread;
- wherein the calling of the custom handler to upload the exception information of the sub-thread to the server comprises:
- printing the exception information of the sub-thread;
- and
- wherein the printing of the exception information of the sub-thread comprises:
- calling a second default sub-thread exception handler of an Android system to print the exception information of the sub-thread.
A non-transitory computer-readable storage medium having stored thereon instructions executable by a processor to perform operations comprising:
- in response to an exception occurring in a sub-thread, calling a custom handler to process the exception;
- and
- in response to an exception occurring in a main thread, restarting a message loop of a looper after the message loop is stopped, and capturing the exception in the main thread;
- wherein the restarting and the capturing comprise:
- triggering a loop module starting loop after the message loop of the looper is stopped, and starting the message loop of the looper and capturing the exception in the main thread in the loop module starting loop;
- and
- wherein the triggering of the loop module starting loop further comprises:
- printing and processing the exception information of the main thread while the exception in the main thread is captured in the loop module starting loop.
Dependencies are inferred from the claim text.