forked from aidlearning/AidLearning-FrameWork
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusbcamera.java
More file actions
50 lines (42 loc) · 1.68 KB
/
Copy pathusbcamera.java
File metadata and controls
50 lines (42 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.aidlux.usbcamera;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
import org.acra.ReportField;
import org.acra.data.CrashReportData;
import org.acra.sender.ReportSender;
import org.acra.sender.ReportSenderException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class AcraFileSender implements ReportSender {
@Override
public void send(Context context, CrashReportData report) throws ReportSenderException {
String error_log = "";
error_log += report.getString(ReportField.LOGCAT);
// final String storagePath = context.getExternalFilesDir(null).getAbsolutePath() + File.separator + "USBCamera";
final String storagePath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "USBCamera";
final String crashFileName = "CrashReport.txt";
final File storageDir = new File(storagePath);
if (!storageDir.exists()) {
storageDir.mkdir();
}
String crashFilePath = storagePath + File.separator + crashFileName;
try {
File file = new File(crashFilePath);
FileOutputStream out = new FileOutputStream(file);
OutputStreamWriter writer = new OutputStreamWriter(out);
writer.append(error_log);
writer.close();
out.flush();
out.close();
Log.i("Acra", "Crash log saved.");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}