2010-07-22 5 views

Répondre

6

Log Collector a son code source disponible sur Google Code. Ils appellent simplement logcat. Voir ici: android-log-collector - SendLogActivity.java

Voici la partie clé:

ArrayList<String> commandLine = new ArrayList<String>(); 
commandLine.add("logcat");//$NON-NLS-1$ 
commandLine.add("-d");//$NON-NLS-1$ 
ArrayList<String> arguments = ((params != null) && (params.length > 0)) ? params[0] : null; 

if (null != arguments){ 
    commandLine.addAll(arguments); 
} 

Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[0])); 
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); 

String line; 
while ((line = bufferedReader.readLine()) != null){ 
    log.append(line); 
    log.append(App.LINE_SEPARATOR); 
} 
+1

lien de EboMike conduit maintenant à 404, ici où il propose: http://code.google.com/p/android-log-collector/source/browse/trunk/ src/com/xtralogic/android/logcollector/SendLogActivity.java? r = 2 – Inoy

+0

(Le lien dans la réponse est mis à jour, j'ai aussi copié la partie clé dans la réponse) – EboMike

0

Vous pouvez utiliser le système de rapport intégré bug. Plus d'informations sur mon blog ici: http://blog.tomtasche.at/2012/10/use-built-in-feedback-mechanism-on.html

ApplicationErrorReport report = new ApplicationErrorReport(); 
report.packageName = report.processName = getApplication() 
    .getPackageName(); 
report.time = System.currentTimeMillis(); 
report.type = ApplicationErrorReport.TYPE_CRASH; 
report.systemApp = false; 

ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo(); 
crash.exceptionClassName = e.getClass().getSimpleName(); 
crash.exceptionMessage = e.getMessage(); 

StringWriter writer = new StringWriter(); 
PrintWriter printer = new PrintWriter(writer); 
e.printStackTrace(printer); 

crash.stackTrace = writer.toString(); 

StackTraceElement stack = e.getStackTrace()[0]; 
crash.throwClassName = stack.getClassName(); 
crash.throwFileName = stack.getFileName(); 
crash.throwLineNumber = stack.getLineNumber(); 
crash.throwMethodName = stack.getMethodName(); 

report.crashInfo = crash; 

Intent intent = new Intent(Intent.ACTION_APP_ERROR); 
intent.putExtra(Intent.EXTRA_BUG_REPORT, report); 
startActivity(intent); 
+0

[Voici une discussion sur ces messages sur Meta] (http : //meta.stackexchange.com/q/153352/152134) –

Questions connexes