eleme / lancet

A lightweight and fast AOP framework for Android App and SDK developers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

并不能 hook 未重写方法

siyehua opened this issue · 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();
//    }
}
commented

Insert(mayCreateSuper = true)

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。