Giter Site home page Giter Site logo

crashhandler's Introduction

CrashHandler

Download

Library to handle crash for Android . Especially that after crash,app will restart the stack top activity when API >=21.
(minSdkVersion=14).

Features:

  1. Prompt the user friendly when crash happend.
  2. Can save detailed crash information to SDcard.
  3. Can completely exit the app after crash when API >=21.
  4. Can truly restart app from initial activity but not stack top activity.
See more details and principle analysis at my blog post: Android Crash Handle 中文文档

Demo

Usage

Step 1

Add dependencies in build.gradle.
dependencies {  
  compile 'com.tuzhenlei:crashhandler:1.0.1'
}
Or Maven:
<dependency>
  <groupId>com.tuzhenlei</groupId>
  <artifactId>crashhandler</artifactId>
  <version>1.0.1</version>
  <type>pom</type>
</dependency>
Or You can download a jar from GitHub's releases page.

Step 2

init CrashHandler in your Application as : ​
CrashHandler.getInstance().init(this, BuildConfig.DEBUG);

or init as: ​
CrashHandler.getInstance().init(this, BuildConfig.DEBUG, true, 0, MainActivity.class);

/**  
param1: this  
param2: Whether to save the log to SDcard (/storage/emulated/0/Crash); Suggest save for debugging in debug mode.
param3: Whether to restart app after crash.
param4: restart after how many milliseconds are.
param5: your app's first activity.(such as splashActivity)
*/

More property settings

set the app close animation

CrashHandler.setCloseAnimation(android.R.anim.fade_out);

set custom crash tip

CrashHandler.setCrashTip("自定义提示信息");

set custom Toast

CrashHandler.setCustomToast(toast);

if you want to save crash log in SD card, please set the second params of "init ( params application, isSaveLogInSDcard)" on true, just like:

CrashHandler.getInstance().init(this, true);

Contact me

If you have a better idea or way, please let me know , thanks~
Email: [email protected]
My Blog

License

Copyright 2017 tuzhenlei

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

crashhandler's People

Contributors

tuzhenlei avatar

Stargazers

Aya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.