SandHook icon indicating copy to clipboard operation
SandHook copied to clipboard

Fragment onResume方法 出现不回掉情况

Open enjoyMiracle opened this issue 5 years ago • 4 comments

请问代码指令太短,是否会导致hook失效

hook Fragment onResume方法 出现不回掉情况

package android.support.v4.app public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener, LifecycleOwner { /** * Called when the fragment is visible to the user and actively running. * This is generally * tied to {@link Activity#onResume() Activity.onResume} of the containing * Activity's lifecycle. */ @CallSuper public void onResume() { mCalled = true; } }

XposedHelpers.findAndHookMethod(Fragment.class, "onResume", new SingletonXC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Fragment fragment = (Fragment) param.thisObject; String fragmentName = fragment.getClass().getName(); Log.i("[Fragment onResume ] == " + fragmentName); } });

日志未输出Fragment的onResume调用,也没有错误日志输出,但是demo程序是使用了Fragment的

机型: meizuPro 6s 系统: android7.1.1

enjoyMiracle avatar May 01 '19 10:05 enjoyMiracle

没反应 SandHookConfig.DEBUG = true 试试,这个一定要在最前面正确配置,否则很可能无法生效,SandHookConfig.DEBUG 跟你的 app 是否 debuggable 保持一致

ganyao114 avatar May 04 '19 07:05 ganyao114

是跟我插件debuggable一致,还是需要被hook的app一致

enjoyMiracle avatar May 06 '19 04:05 enjoyMiracle

app,不放心直接填 true 就可以了

ganyao114 avatar May 06 '19 04:05 ganyao114

为什么要 SandHookConfig.DEBUG = true ,这样是说不能用于线上吗 @ganyao114

zhiqinliao avatar Jul 20 '20 09:07 zhiqinliao