1 Java层加打印和打印调用栈
Slog.e(TAG,"freeformWindowManagement: " + freeformWindowManagement);
Log.e(TAG,"mHasFreeformWorkspaceSupport:" + mHasFreeformWorkspaceSupport);
import android.os.Debug;
Debug.getCallers(10);
2 sleep
try{
Thread.sleep(2000);
}catch (Exception e ){
}
3 打印类名,方法名,文件名和行数
public class printDebug {
public static void printLine(){
StackTraceElement[] trace = new Throwable().getStackTrace();
//下标为0的元素是上一行语句的信息, 下标为1的才是调用printLine的地方的信息
StackTraceElement tmp = trace[1];
System.out.println( "XXX: "+tmp.getClassName() + "." + tmp.getMethodName()
+ "(" + tmp.getFileName() + ":" + tmp.getLineNumber() + ")");
}
public static void printLine(String content){
StackTraceElement[] trace = new Throwable().getStackTrace();
//下标为0的元素是上一行语句的信息, 下标为1的才是调用printLine的地方的信息
StackTraceElement tmp = trace[1];
System.out.println( "XXX: "+tmp.getClassName() + "." + tmp.getMethodName()
+ "(" + tmp.getFileName() + ":" + tmp.getLineNumber() + ") "
+ content);
}
}