lancet icon indicating copy to clipboard operation
lancet copied to clipboard

并不能 hook 未重写方法

Open siyehua opened this issue 5 years ago • 2 comments

 @TargetClass("androidx.appcompat.app.AppCompatActivity")
    @Proxy("onDestroy")
    public void onDestroy() {
        Log.e("siyehua", "onDestroy");
        Origin.callVoid();
    }

如果不重写onDestroy(),则无效

public class Main2Activity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        setContentView(R.layout.activity_main2);
    }

//    @Override
//    protected void onDestroy() {
//        super.onDestroy();
//    }
}

siyehua avatar Jan 10 '20 09:01 siyehua

Insert(mayCreateSuper = true)

dieyidezui avatar Jan 12 '20 03:01 dieyidezui

Insert(mayCreateSuper = true)

我加了mayCreateSuper = true,似乎还是没有成功织入。

    @Insert(value = "startActivity", mayCreateSuper = true)
    @TargetClass("xx.xx.MyActivity")
    // @TargetClass(value = "android.support.v4.app.FragmentActivity", scope = Scope.ALL)
    public void hookStartActivity(Intent intent) {
        Origin.callVoid();
        Log.d("hjwaj", "hookStartActivity");
    }

@TargetClass("xx.xx.MyActivity") 时,加不加mayCreateSuper = true都可以织入。 @TargetClass(value = "android.support.v4.app.FragmentActivity")时,不管设置什么scope,不管加不加mayCreateSuper = true,在MyActivity调用startActivity时,都没有成功织入。

版本是1.0.5。

HJWAJ avatar Apr 28 '20 03:04 HJWAJ