tmp
This commit is contained in:
@@ -28,6 +28,7 @@ import com.fm.openinstall.OpenInstall;
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||
import com.shayu.phonelive.utils.LogUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
||||
@@ -137,6 +138,7 @@ public class AppContext extends CommonAppContext {
|
||||
CrashSaveBean.getInstance().setStartTime(System.currentTimeMillis());
|
||||
registerError();
|
||||
registerFirebaseCrash();
|
||||
LogUtils.start(this);
|
||||
sInstance = this;
|
||||
L.setDeBug(BuildConfig.DEBUG);
|
||||
AppEventsLogger.activateApp(this);
|
||||
|
||||
61
app/src/main/java/com/shayu/phonelive/utils/LogUtils.java
Normal file
61
app/src/main/java/com/shayu/phonelive/utils/LogUtils.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package com.shayu.phonelive.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.yunbao.common.utils.FileUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
public class LogUtils {
|
||||
public static void start(Context context) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
String[] exec = new String[]{
|
||||
"logcat",
|
||||
"-c"
|
||||
};
|
||||
Runtime.getRuntime().exec(exec).waitFor();
|
||||
|
||||
exec = new String[]{
|
||||
"logcat",
|
||||
"-v",
|
||||
"-d",
|
||||
"time"
|
||||
};
|
||||
|
||||
Process process = Runtime.getRuntime().exec(exec);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()), 1024);
|
||||
String line;
|
||||
File saveFile = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath());
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line).append("\n");
|
||||
if (builder.length() > 65500) {
|
||||
FileUtil.saveAddStringToFile(saveFile, builder.toString(), "logcat.log");
|
||||
builder.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
exec = new String[]{
|
||||
"logcat",
|
||||
"-c"
|
||||
};
|
||||
Runtime.getRuntime().exec(exec).waitFor();
|
||||
bufferedReader.close();
|
||||
start(context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ToastUtil.show("");
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user