Android Wear - code to read LogCat output programmatically and continuously is not working -
hi wrote code read logcat output continuously within background thread started background service in app. not think there errors in code it's not working.
in thread, have:
@override public void run() { process process = null; string cmd = "logcat -v time | grep 'audiofocus requestaudiofocus()'"; try { process = runtime.getruntime().exec("su"); dataoutputstream os = new dataoutputstream(process.getoutputstream()); os.writebytes("logcat -c" + "\n"); os.writebytes(cmd + "\n"); os.flush(); } catch(exception e) { } bufferedreader reader = new bufferedreader(new inputstreamreader(process.getinputstream())); string line; try { while ( (line = reader.readline()) != null ) { log.e(staticval.tag, line); // code write line own log file } } catch(exception e) { } }
i added permission manifest:
<uses-permission android:name="android.permission.read_logs" />
however, when plug device pc , test android studio, log.e(staticval.tag, line);
did not print out results , nothing wrote own log file.
any appreciated!
(directly run logcat -v time | grep 'audiofocus requestaudiofocus()'
on device through adb terminal results expected)
Comments
Post a Comment