Awesome Open Source
Awesome Open Source
Sponsorship

NeverCrash

Download Jitpack API License Blog QQGroup

NeverCrash for Android 一个全局捕获Crash的库。信NeverCrash,永不Crash。

Gif 展示

Image

引入

Maven:

<dependency>
  <groupId>com.king.thread</groupId>
  <artifactId>nevercrash</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

Gradle:

compile 'com.king.thread:nevercrash:1.0.0'

Lvy:

<dependency org='com.king.thread' name='nevercrash' rev='1.0.0'>
  <artifact name='$AID' ext='pom'></artifact>
</dependency>
如果Gradle出现compile失败的情况,可以在Project的build.gradle里面添加如下:(也可以使用上面的GitPack来complie)
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


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
java (29,497
thread (77
crash (36
handler (36
exception (16

Find Open Source By Browsing 7,000 Topics Across 59 Categories