当前位置:网站首页>App global exception capture
App global exception capture
2022-07-03 15:00:00 【Mo Mo 0830】
App Exception global capture , Prevent application crash fall ( Not against ANR).
/** * Exception trapping * */
public class NeverCrash {
private CrashHandler mCrashHandler;
private static NeverCrash mInstance;
private NeverCrash(){
}
private static NeverCrash getInstance(){
if(mInstance == null){
synchronized (NeverCrash.class){
if(mInstance == null){
mInstance = new NeverCrash();
}
}
}
return mInstance;
}
public static void init(CrashHandler crashHandler){
getInstance().setCrashHandler(crashHandler);
}
private void setCrashHandler(CrashHandler crashHandler){
mCrashHandler = crashHandler;
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
for (;;) {
try {
Looper.loop();
} catch (Throwable e) {
if (mCrashHandler != null) {
// Catch exception handling
mCrashHandler.uncaughtException(Looper.getMainLooper().getThread(), e);
}
}
}
}
});
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
if(mCrashHandler!=null){
// Catch exception handling
mCrashHandler.uncaughtException(t,e);
}
}
});
}
public interface CrashHandler{
void uncaughtException(Thread t,Throwable e);
}
}
stay application Use in :
NeverCrash.init {
t, e ->
Log.d(TAG, Log.getStackTraceString(e))
}
边栏推荐
- NOI OPENJUDGE 1.4(15)
- Dllexport and dllimport
- Incluxdb2 buckets create database
- 5-1 blocking / non blocking, synchronous / asynchronous
- Piwigo 2.7.1 sqli learning
- Rasterization: a practical implementation (2)
- 2022/02/14
- The picture quality has been improved! LR enhancement details_ Lightroom turns on AI photo detail enhancement: picture clarity increases by 30%
- Leetcode the smallest number of the rotation array of the offer of the sword (11)
- mmdetection 学习率与batch_size关系
猜你喜欢
![[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University](/img/83/922efb4f88843f1b7feaccf2b515b9.jpg)
[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University

PS tips - draw green earth with a brush
![[engine development] in depth GPU and rendering optimization (basic)](/img/71/abf09941eb06cd91784df50891fe29.jpg)
[engine development] in depth GPU and rendering optimization (basic)

Composite type (custom type)

5.2-5.3

Implement Gobang with C language
![[graphics] adaptive shadow map](/img/93/a6a3c7716331368c90c2c86da11f55.jpg)
[graphics] adaptive shadow map

Vs+qt multithreading implementation -- run and movetothread

Solve the problem that PR cannot be installed on win10 system. Pr2021 version -premiere Pro 2021 official Chinese version installation tutorial

5-1 blocking / non blocking, synchronous / asynchronous
随机推荐
mmdetection 学习率与batch_size关系
什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
Zzuli:1054 monkeys eat peaches
NOI OPENJUDGE 1.4(15)
Tencent internship interview sorting
Tensor 省略号(三个点)切片
TPS61170QDRVRQ1
[engine development] rendering architecture and advanced graphics programming
QT program font becomes larger on computers with different resolutions, overflowing controls
牛客 BM83 字符串变形(大小写转换,字符串反转,字符串替换)
Bucket sorting in C language
My QT learning path -- how qdatetimeedit is empty
Zzuli:1047 logarithmic table
Zzuli:1041 sum of sequence 2
【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
Awvs batch operation script
2022/02/14
Global and Chinese markets for indoor HDTV antennas 2022-2028: Research Report on technology, participants, trends, market size and share
Zzuli:1049 square sum and cubic sum
Zzuli:1059 highest score