代码:
Java.perform(function() { var cls_Activity = Java.use("android.app.Activity"); cls_Activity.onCreate.overload('android.os.Bundle').implementation = function(arg) { console.log("================ onCreate =============="); //printStack(); showStacks3("xxx"); return this.onCreate(arg); } }); /* function showStacks1() { console.log("xxx2"); send(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Exception").$new())); } */ function showStacks2(name) { var Exception = Java.use("java.lang.Exception"); var ins = Exception.$new("Exception"); var straces = ins.getStackTrace(); if (straces != undefined && straces != null) { var strace = straces.toString(); var replaceStr = strace.replace(/,/g, "\n"); console.log("=============================" + name + " Stack strat======================="); console.log(replaceStr); console.log("=============================" + name + " Stack end======================= "); Exception.$dispose(); } } function showStacks3(str_tag) { var Exception= Java.use("java.lang.Exception"); var ins = Exception.$new("Exception"); var straces = ins.getStackTrace(); if (undefined == straces || null == straces) { return; } console.log("=============================" + str_tag + " Stack strat======================="); console.log(""); for (var i = 0; i < straces.length; i++) { var str = " " + straces[i].toString(); console.log(str); } console.log(""); console.log("=============================" + str_tag + " Stack end======================= "); Exception.$dispose(); }