android - Read logs from Logcat without killing the tablet -


i have read logs logcat , send them server through udp.

for task have used code: https://github.com/chemik/logcatudp

the main problem of code async thread launched enters while(true) loop drains tablet's battery on long run.

is there way logs in real time without using busy wait that? without adding sleep(some_milliseconds) reduce problem?

it great use sort of event listener haven't found one. have searched in every similar library without success.

the code following:

while (true) {     string sendingline = "";     // assume log writes whole lines     if (bufferedreader.ready()) {         logline = bufferedreader.readline();         sendingline += logline + system.getproperty("line.separator");         datagrampacket packet = new datagrampacket(sendingline.getbytes(), sendingline.length(),                         inetaddress.getbyname(mconfig.mdestserver), mconfig.mdestport);         try {             msocket.send(packet);             ... 

any idea? thanks.

finally answer put thread.sleep(10) in while(true) loop.

it may seem strange, 10ms of sleep reduces battery usage 40% 1%.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -