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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lf12345678910/article/details/66974729

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]); 

猜你喜欢

转载自blog.csdn.net/lf12345678910/article/details/66974729