Android: how to share code between projects signed with the same certificate

前端 未结 2 1781
迷失自我
迷失自我 2020-12-24 04:38

In Android documentation concerning code signing we can read: \"By signing multiple applications with the same certificate and using signature-based permissions checks,

2条回答
  •  离开以前
    2020-12-24 05:18

    Say you want to call a public function of the dynamically loaded class. Use the following code snippet:

    Context friendContext = this.createPackageContext("packageName", Context.CONTEXT_INCLUDE_CODE);
    Class friendClass = friendContext.getClassLoader().loadClass("packageName.className");
    Class noparams[] = {}; //say the function (functionName) required no inputs
    friendClass.getMethod("functionName", noparams).invoke(friendClass.newInstance(), null);
    

提交回复
热议问题