IP Library Granted Patent US 12675348
Granted Patent B2
US 12675348 · App. 18/335,146 · Granted Jul 7, 2026

Processing exception in android thread

Inventor: Dongjiao Tang (Huizhou, CN)
Assignee: HUIZHOU TCL MOBILE COMMUNICATION CO., LTD.
G06F9/546G06F9/4812G06F2209/481
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12675348
App. No.
18/335,146
Granted
Jul 7, 2026
Kind
B2
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.

Claims (51)

1 . 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.

2 . The method of claim 1 , wherein the calling of the custom handler further comprises:

calling the custom handler to upload exception information of the sub-thread to a server.

3 . The method of claim 1 , 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.

4 . The method of claim 3 , 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.

5 . The method of claim 1 , 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.

6 . The method of claim 5 , 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.

7 . The method of claim 6 , wherein the printing and processing of the exception information of the main thread comprise:

uploading the exception information of the main thread to a server.

8 . The method of claim 1 , wherein the restarting of the message loop further comprises:

establishing a loop module starting loop for restarting the loop module in the looper after the looper stops the message loop and capturing the exception in the main thread.

9 . The method of claim 8 , wherein the establishing of the loop module starting loop comprises:

delivering a loop establishing message to the main thread to enable the main thread to establish the loop module starting loop while the main thread executes the loop establishing message.

10 . The method of claim 5 , wherein the loop module starting loop is a while loop.

11 . 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.

12 . The terminal of claim 11 , 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.

13 . The terminal of claim 11 , wherein the calling of the custom handler further comprises:

calling the custom handler to upload exception information of the sub-thread to a server.

14 . The terminal of claim 11 , 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.

15 . The terminal of claim 14 , 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.

16 . The terminal of claim 15 , wherein the printing and processing of the exception information of the main thread comprise:

uploading the exception information of the main thread to a server.

17 . 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.