Question

I have an application/phone which I am developing to be given to people who will be using it in remote areas and not so tech-savvy. I want a mechanism to be able to read their log files remotely. The android app is making use of the logcat logging. I want to be able to just read my logs for my app by some remote mechanism. I was thinking more along the lines of reading the logcat then posting that up periodically to a REST service where I can database these. So question is how do I read the Logcat files programatically from my app?

Was it helpful?

Solution

If you invoke:

Proccess p = Runtime.getRuntime().exec("logcat");
InputStream in = p.getInputStream();
//code to process the InputStream

I honestly do not know the entire process of getting the input stream back, but the code above will allow your app to read the logcat file. You can go here for possible command-line paramaters for "logcat". The exec method runs the string through a linux shell, btw.

You must have the permission READ_LOGS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top