Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mmm-rain
AndroidUtilCode
提交
b5d030c9
A
AndroidUtilCode
项目概览
mmm-rain
/
AndroidUtilCode
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AndroidUtilCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b5d030c9
编写于
4月 10, 2018
作者:
B
Blankj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
see 04/10 log
上级
46a5a9c0
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
41 addition
and
29 deletion
+41
-29
README-CN.md
README-CN.md
+1
-1
README.md
README.md
+1
-1
app/src/main/java/com/blankj/androidutilcode/UtilsApp.java
app/src/main/java/com/blankj/androidutilcode/UtilsApp.java
+3
-9
build.gradle
build.gradle
+2
-2
update_log.md
update_log.md
+1
-0
utilcode/README-CN.md
utilcode/README-CN.md
+1
-1
utilcode/README.md
utilcode/README.md
+1
-1
utilcode/src/main/java/com/blankj/utilcode/util/CrashUtils.java
...de/src/main/java/com/blankj/utilcode/util/CrashUtils.java
+31
-14
未找到文件。
README-CN.md
浏览文件 @
b5d030c9
...
...
@@ -41,7 +41,7 @@
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.13.
9
-brightgreen.svg
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.13.
10
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apisvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
README.md
浏览文件 @
b5d030c9
...
...
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.13.
9
-brightgreen.svg
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.13.
10
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apisvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
app/src/main/java/com/blankj/androidutilcode/UtilsApp.java
浏览文件 @
b5d030c9
...
...
@@ -66,21 +66,15 @@ public class UtilsApp extends BaseApplication {
.
setConsoleFilter
(
LogUtils
.
V
)
// log 的控制台过滤器,和 logcat 过滤器同理,默认 Verbose
.
setFileFilter
(
LogUtils
.
V
)
// log 文件过滤器,和 logcat 过滤器同理,默认 Verbose
.
setStackDeep
(
1
);
// log 栈深度,默认为 1
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
LogUtils
.
d
(
config
.
toString
());
}
}).
start
();
LogUtils
.
d
(
config
.
toString
());
}
@SuppressLint
(
"MissingPermission"
)
private
void
initCrash
()
{
CrashUtils
.
init
(
new
CrashUtils
.
OnCrashListener
()
{
@Override
public
void
onCrash
(
Throwable
e
)
{
e
.
printStackTrace
(
);
public
void
onCrash
(
String
crashInfo
,
Throwable
e
)
{
LogUtils
.
e
(
crashInfo
);
restartApp
();
}
});
...
...
build.gradle
浏览文件 @
b5d030c9
...
...
@@ -33,8 +33,8 @@ ext {
min_sdk_version
=
14
target_sdk_version
=
27
version_code
=
1
_013_0
09
version_name
=
'1.13.
9
'
// E.g 1.9.72 => 1,009,072
version_code
=
1
_013_0
10
version_name
=
'1.13.
10
'
// E.g 1.9.72 => 1,009,072
// App dependencies
support_version
=
'27.1.0'
...
...
update_log.md
浏览文件 @
b5d030c9
*
18/04/10 完善 OnCrashListener 回调崩溃信息,发布 1.13.10 版本
*
18/04/09 修复静默安装重载错误,发布 1.13.9 版本
*
18/04/08 修复获取栈顶 Activity 链表为空的异常,获取栈顶 Activity 放到 Utils 中,发布 1.13.8 版本
*
18/04/06 新增 GsonUtils 及单元测试
...
...
utilcode/README-CN.md
浏览文件 @
b5d030c9
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
compile
'com.blankj:utilcode:1.13.
9
'
compile
'com.blankj:utilcode:1.13.
10
'
```
...
...
utilcode/README.md
浏览文件 @
b5d030c9
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
compile
'com.blankj:utilcode:1.13.
9
'
compile
'com.blankj:utilcode:1.13.
10
'
```
...
...
utilcode/src/main/java/com/blankj/utilcode/util/CrashUtils.java
浏览文件 @
b5d030c9
...
...
@@ -8,10 +8,12 @@ import android.os.Environment;
import
android.support.annotation.NonNull
;
import
android.support.annotation.RequiresPermission
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.lang.Thread.UncaughtExceptionHandler
;
import
java.text.Format
;
import
java.text.SimpleDateFormat
;
...
...
@@ -85,9 +87,21 @@ public final class CrashUtils {
}
return
;
}
if
(
sOnCrashListener
!=
null
)
{
sOnCrashListener
.
onCrash
(
e
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
CRASH_HEAD
);
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
e
.
printStackTrace
(
pw
);
Throwable
cause
=
e
.
getCause
();
while
(
cause
!=
null
)
{
cause
.
printStackTrace
(
pw
);
cause
=
cause
.
getCause
();
}
pw
.
flush
();
sb
.
append
(
sw
.
toString
());
final
String
crashInfo
=
sb
.
toString
();
Date
now
=
new
Date
(
System
.
currentTimeMillis
());
String
fileName
=
FORMAT
.
format
(
now
)
+
".txt"
;
final
String
fullPath
=
(
dir
==
null
?
defaultDir
:
dir
)
+
fileName
;
...
...
@@ -98,25 +112,28 @@ public final class CrashUtils {
sExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
PrintWriter
p
w
=
null
;
BufferedWriter
b
w
=
null
;
try
{
pw
=
new
PrintWriter
(
new
FileWriter
(
fullPath
,
false
));
pw
.
write
(
CRASH_HEAD
);
e
.
printStackTrace
(
pw
);
Throwable
cause
=
e
.
getCause
();
while
(
cause
!=
null
)
{
cause
.
printStackTrace
(
pw
);
cause
=
cause
.
getCause
();
}
bw
=
new
BufferedWriter
(
new
FileWriter
(
fullPath
,
false
));
bw
.
write
(
crashInfo
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
pw
!=
null
)
{
pw
.
close
();
if
(
bw
!=
null
)
{
try
{
bw
.
close
();
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
}
}
}
}
});
if
(
sOnCrashListener
!=
null
)
{
sOnCrashListener
.
onCrash
(
crashInfo
,
e
);
}
if
(
DEFAULT_UNCAUGHT_EXCEPTION_HANDLER
!=
null
)
{
DEFAULT_UNCAUGHT_EXCEPTION_HANDLER
.
uncaughtException
(
t
,
e
);
}
...
...
@@ -239,6 +256,6 @@ public final class CrashUtils {
}
public
interface
OnCrashListener
{
void
onCrash
(
Throwable
e
);
void
onCrash
(
String
crashInfo
,
Throwable
e
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录