Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Commit

Permalink
Modifi the api. Could send log when the app start.
Browse files Browse the repository at this point in the history
  • Loading branch information
msdx committed Jun 7, 2014
1 parent 68c7206 commit 5f3a6ed
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 61 deletions.
3 changes: 1 addition & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:label="@string/app_name">
<activity
android:name="com.githang.android.crash.MainActivity"
android:label="@string/app_name" >
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ android crash 是我写的一个Android程序崩溃信息处理框架。通过
CrashEmailReport report = new CrashEmailReport(this);
report.setReceiver("[email protected]");
report.setSender("[email protected]");
report.setPass("xxxxxxxx");
report.setSendPassword("xxxxxxxx");
report.setHost("smtp.163.com");
report.setPort("465");
report.start();
```

注意:发送邮件需依赖三个包,分别是:activation.jar, additionnal.jar, mail.jar。可以从项目的libs文件夹中获取。
12 changes: 0 additions & 12 deletions res/menu/main.xml

This file was deleted.

11 changes: 0 additions & 11 deletions res/values-v11/styles.xml

This file was deleted.

12 changes: 0 additions & 12 deletions res/values-v14/styles.xml

This file was deleted.

20 changes: 0 additions & 20 deletions res/values/styles.xml

This file was deleted.

18 changes: 15 additions & 3 deletions src/com/githang/android/crash/AbstractCrashReportHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,23 @@ public abstract class AbstractCrashReportHandler implements CrashListener {
public AbstractCrashReportHandler(Context context) {
mContext = context;
CrashHandler handler = CrashHandler.getInstance();
handler.init(getLogDir(context), this);
Thread.setDefaultUncaughtExceptionHandler(handler);
final File file = getLogFile(context);
handler.init(file, this);
if(file.length() > 10) {
new Thread(new Runnable() {
@Override
public void run() {
sendReport(buildTitle(mContext), buildBody(mContext), file);
}
}).start();
}
}

public void start() {
Thread.setDefaultUncaughtExceptionHandler(CrashHandler.getInstance());
}

protected File getLogDir(Context context) {
protected File getLogFile(Context context) {
return new File(context.getFilesDir(), "crash.log");
}

Expand Down

0 comments on commit 5f3a6ed

Please sign in to comment.