Android - sharing activities/code between different applications

ⅰ亾dé卋堺 提交于 2019-12-10 12:59:21

问题


I have a single android app with a custom logo, some custom json service endpoints, occasional custom text, and possibly a custom color scheme.

For my client this particular app will need to be rebranded and distributed as an entirely different app about 5-10 times over. So I'm looking for way to reuse the most amount of code - the activities and services will be identical except for the custom things I mentioned.

First off, how can I share projects in the sense that one project will hold all code (including activities), and the others just modify a few values. I can't think of a smart way to share both service code and activity code with the occasional value thrown in via properties.

Do android layout/string resource files have the ability to pull from properties? Can activities be bundled inside a jar and shared with other projects?


回答1:


You can use Android library project to share the common code. Start by reading this article




回答2:


You do not have to have different java namespaces, they can be common for all projects. All you need is to replace resources and modify manifest to contain different namespace for each application. There is no problem with several applications having the same name of classes inside. Unless you want to rebrand it all the way user could not find it is actually the same code, of course.



来源:https://stackoverflow.com/questions/11722379/android-sharing-activities-code-between-different-applications

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!