Android的:如何共享相同的证书签名的项目之间code [英] Android: how to share code between projects signed with the same certificate

查看:127
本文介绍了Android的:如何共享相同的证书签名的项目之间code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的文档关于code签约,我们可以读到: 的签署多个应用程序具有相同的证书,并使用基于特征的权限检查,您的应用程序能份额code 并以安全的方式数据。

In Android documentation concerning code signing we can read: "By signing multiple applications with the same certificate and using signature-based permissions checks, your applications can share code and data in a secure manner."

如何正是这样code共享可以做什么?是否有可能释放的主要应用和多个可更换插件然后发现他们在运行时?是什么来源$ C ​​$ C样子,有什么优势标准的意图调用自/至不同的APK包?

How exactly such code sharing can be done? Is it possible to release main application and multiple exchangeable plugins then discover them at runtime? What does source code looks like and what are advantages over "standard" intents calls from/to different APK packages?

推荐答案

使用Context.createPackageContext()来实例化一个包另外的.apk你有兴趣,如果使用相同的证书和你签约,你是两者都使用同一个共享的用户ID,那么你可以使用该标志来加载其code到你的过程中,让你从上下文的类加载器和实例化任何类你想要的。

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.

否则,如果他们没有签署相同,显式地使用相同的共享使用的ID,你只能加载它的资源。

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

请注意,您不能更改共享用户ID的应用程序(别的东西,或有和没有一个共享的用户ID之间移动)一旦应用程序市场。

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.

这篇关于Android的:如何共享相同的证书签名的项目之间code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆