Invocation (call stack ). I know three methods: one is the traditional Java method, the other is the android method, and the third is the exeption or throwable method. First,Getstacktrace () is a traditional Java method. In your code, you can use thread. currentthread (). getstacktrace () to obtain a stacktraceelement array and print the array. Example 1: Stacktraceelement st [] = thread. currentthread (). getstacktrace (); For (INT I = 0; I <St. length; I ++) system. out. println (I + ":" + st [I]); in this way, you can print out the calling level (call stack) of the code here. Second, Using Android. util. log. WTF () We can directly use android. util. log. WTF () series functions to output a log. when the log is output, it prints the code execution path (call stack) at this time. Example 2: log. WTF (TAG, "this a fake erro "); Third, Exception Example 3: Try {
Cm. setprimaryclip (clipdata. newrawuri (null, Uri. parse (text. tostring ();} catch (exception e ){
E. printstacktrace (); }Example 4: Try {
...... Catch (exception e ){
Log. WTF ("Robin", e);} note that we can directly build an exeption or throwable.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service