1. Code Call Tree View
2. Error code location information hint
function function:
/** output the message info in Logcat, and gives the full call tree */public static void Messagewithsrctree (String info) {stacktraceelement[] in the code that outputs the information Elem = Thread.CurrentThread (). Getstacktrace ()//from the current location, get code call stack for (stacktraceelement e:elem) {String str = E.getfilename () + "" + e.getlinenumber () + "line:" + e.getclassname () + "+" + E.getmethodname () + "()"; Gdx.app.error (info, str);//Output call location information// <span style= "White-space:pre" ></SPAN>LOG.E (info, str);// SYSTEM.OUT.PRINTLN (info + " " + str);}}
<pre name= "code" class= "Java" >
<span style= "White-space:pre" ></span>//when a try block error, give the current code location, error message//try{...} catch (Exception e) {tools.messagewithsrcsite ("Error executing try{}"! "); }
<span style= "White-space:pre" ></span>/** output hint info in Logcat and gives the output of the message in the code where the call is */public static void Messagewithsrcsite (String info) {stacktraceelement[] Elem = Thread.CurrentThread (). Getstacktrace ();//from the current position, Gets the code call stack stacktraceelement e = elem[3];//only gets the code location that called the function, does not get the full call Tree string str = e.getfilename () + "" + e.getlinenumber () + "line: "+ e.getclassname () +", " + e.getmethodname () +" () "; Gdx.app.error (info, str);//Output call location information// <span style= "White-space:pre" ></SPAN>LOG.E (info, str);// SYSTEM.OUT.PRINTLN (info + " " + str);}
Line Cheng Stacks stacktrace usage, code call tree view, error code location information hint, code class name Package name File name view