NeverCrash for Android 一个全局捕获Crash的库。信NeverCrash,永不Crash。
<dependency>
<groupId>com.king.thread</groupId>
<artifactId>nevercrash</artifactId>
<version>1.0.0</version>
<type>pom</type>
</dependency>
compile 'com.king.thread:nevercrash:1.0.0'
<dependency org='com.king.thread' name='nevercrash' rev='1.0.0'>
<artifact name='$AID' ext='pom'></artifact>
</dependency>
allprojects {
repositories {
maven { url 'https://dl.bintray.com/jenly/maven' }
}
}
核心代码(大道至简)
NeverCrash.init(CrashHandler);
代码示例
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
NeverCrash.init(new NeverCrash.CrashHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
Log.d("Jenly", Log.getStackTraceString(e));
// e.printStackTrace();
showToast(e.getMessage());
}
});
}
private void showToast(final String text){
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(),text,Toast.LENGTH_SHORT).show();
}
});
}
}
如果您喜欢NeverCrash,或感觉NeverCrash帮助到了您,可以点右上角“Star”支持一下,您的支持就是我的动力,谢谢 😃
也可以扫描下面的二维码,请作者喝杯咖啡 ☕
Name: Jenly
Email: jenly1314#gmail.com / jenly1314#vip.qq.com
CSDN: jenly121
Github: jenly1314
加入QQ群: 20867961