2011-12-07 26 views

Odpowiedz

13

można przeczytać tego kodu z aplikacji

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()), 1024); 

bufferedReader.readLine() 

Store to BufferedReader w ciąg lub ciąg konstruktora by sprawdzić logi

tak potrzebne pozwolenie w pliku manifestu:

<uses-permission android:name="android.permission.READ_LOGS"/> 
+0

Czy istnieje sposób na wykonanie tego bez tworzenia innego procesu? coz te wyniki nie są usuwane przy następnym uruchomieniu ... – AbhishekB

+3

Nie widzę, jak uprawnienia 'READ_LOGS' są związane z uruchamianiem logcat – basin

Powiązane problemy