You must request the android.permission.READ_LOGS in your Android
Manifest.
Then you can run the logcat from the command line on the phone, and
just get a dump of the output. I recommend filtering the output for
both AndroidRuntime with the error level only (to gather exceptions
that crashed your app) as well as all messages from your app's log
tag. See below:
Process mLogcatProc = null;
BufferedReader reader = null;
try
{
mLogcatProc = Runtime.getRuntime().exec(new String[]
{"logcat", "-d", "AndroidRuntime:E [Your Log Tag Here]:V *:S"
}); //
$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
reader = new BufferedReader(new InputStreamReader
(mLogcatProc.getInputStream()));
String line;
final StringBuilder log = new StringBuilder();
String separator = System.getProperty("line.separator"); //$NON-
NLS-1$
while ((line = reader.readLine()) != null)
{
log.append(line);
log.append(separator);
}
// do whatever you want with the log. I'd recommend using Intents to
create an email
}
catch (IOException e)
{
...
}
finally
{
if (reader != null)
try
{
reader.close();
}
catch (IOException e)
{
...
}
}
On Mar 13, 2:48 pm, Mike Collins <[email protected]> wrote:
> I know how to use adb's logcat to capture the log information.
> I know how to use logcat inside an adb shell to display the log
> information.
>
> Is it possible to do this from my application on the phone?
>
> I'm trying to get a bit more context than just the call stack
> captured
> when/if my app crashes.
>
> tia,
> mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---