Print thread info Android Java

On Android java code, print stack trace of all the threads owned by current process.

try
{
     Map info = Thread.getAllStackTraces();
    for (Map.Entry<Thread, StackTraceElement[]> entry : info.entrySet())
    {
    Thread th = entry.getKey();
            StackTraceElement[] elms = entry.getValue();

    //print("===> Thread: {0} id:{1} prio:{2} st:{3}",
            //                th.getName(), th.getId(), th.getPriority(), th.getState().toString());

            for (int idx = 0; idx < elms.length; ++idx)
            {
                //print("   {0}:{1}:{2}->{3}",
                    //      elms[idx].getFileName(), elms[idx].getLineNumber(), elms[idx].getClassName(), elms[idx].getMethodName());
            }
     }
}
catch (Exception ex)
{
}

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.