android 函数调用流程 、 android打印程序调用堆栈信息

  • Post author:
  • Post category:其他


new RuntimeException(“here”).fillInStackTrace());

Slog.e(“settings”, ” setOnCheckedChangeListener”,new RuntimeException(“here”).fillInStackTrace());

ActivityManagerService.java

@Override

public void moveTaskToStack(int taskId, int stackId, boolean toTop) {


enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS,

“moveTaskToStack()”);

if (stackId == HOME_STACK_ID) {


Slog.e(TAG, “moveTaskToStack: Attempt to move task ” + taskId + ” to home stack”,

new RuntimeException(“here”).fillInStackTrace());

}

synchronized (this) {


long ident = Binder.clearCallingIdentity();

try {


if (DEBUG_STACK) Slog.d(TAG, “moveTaskToStack: moving task=” + taskId + ” to stackId=”

+ stackId + ” toTop=” + toTop);

mStackSupervisor.moveTaskToStack(taskId, stackId, toTop);

} finally {


Binder.restoreCallingIdentity(ident);

}

}

}

可已输出程序调用的堆栈信息及调用的地方,方便调试。

StackTraceElement st[]= Thread.currentThread().getStackTrace();
for(int i=0;i<st.length;i++)  
Log.d(TAG,i+":"+st[i]); 
for(int i=0;i<st.length;i++)  
Log.d(TAG,i+":"+st[i]); 



版权声明:本文为lf12345678910原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。