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();
}
});
}
}
Name: Jenly
Email: jenly1314@gmail.com / jenly1314@vip.qq.com
CSDN: http://blog.csdn.net/jenly121
Github: https://github.com/jenly1314
微信公众号:
加入QQ群: 20867961