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

前端 未结 2 1783
迷失自我
迷失自我 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:14

    Use Context.createPackageContext() to instantiate a package for another .apk you are interested in. If it is signed with the same cert as yours, AND you are both using the same shared user ID, then you can use the flag to load its code into your process, allowing you to get the ClassLoader from the context and instantiate whatever classes you want.

    Otherwise, if they are not signed the same and explicitly using the same shared used ID, you can only load its resources.

    Please note that you can not change the shared user ID for an application (to something else or moving between having and not having a shared user ID) once that application is on market.

提交回复
热议问题